Repository navigation
Conversation
… input Fixes Issue qBraid#437: loads('') now raises ValidationError (consistent with other invalid inputs) instead of AttributeError when openqasm3 parser encounters malformed/empty input and returns None for node.stop.line. GH007: Jah-yee <jydu_seven@outlook.com>
Fixes qBraid#437: loads('') now raises ValidationError instead of AttributeError.
When an extern function is called as a bare statement (not assigned to a variable), pyqasm returned the raw FunctionCall node from _visit_function_call. The openqasm3 printer's visit_FunctionCall does not add a terminating semicolon; that is done by visit_ExpressionStatement via _end_statement. This caused dumps() to emit extern call lines without semicolons, making the output unparsable by openqasm3.parse. Fix: wrap the extern FunctionCall in qasm3_ast.ExpressionStatement before appending to the result list, so the printer correctly adds the semicolon. Fixes qBraid#438. Co-authored-by: Jah-yee <166608075+Jah-yee@users.noreply.github.com>
Argus reviewAuto-review is off for this repo. Tick the box below to run a review on this PR.
Estimated cost
Tip: you can also comment |
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hi @Jah-yee , thanks for this change! Change looks good overall just a couple of things -
I also do not see any CI checks, can you please push another commit? I will approve the CI run then |
Summary
When an extern function is called as a bare statement (not assigned to a variable), e.g.:
OPENQASM 3.0; extern my_extern(int); my_extern(3);pyqasm.dumps()emitted the call without a terminating semicolon, making the output unparsable byopenqasm3.parse().Root cause
In
_visit_function_call(visitor.py), when the subroutine is anExternDeclaration, the rawFunctionCallnode was appended to the result list. Theopenqasm3.printer.Printer.visit_FunctionCallmethod does not add a semicolon — that is done byvisit_ExpressionStatementvia_end_statement. BareFunctionCallnodes were visited directly, missing the semicolon.Fix
Wrap the extern
FunctionCallinqasm3_ast.ExpressionStatementbefore appending to the result list, ensuring the printer correctly adds the semicolon.Testing
Verified with the reproducer from issue #438: the output now parses cleanly with
openqasm3.parse().Fixes #438.