[BUG] Unusual error when running direct recursion
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Start with the reproducer in the issue: a recursive def test(qubit[1] a, int b) that calls itself with a[0], which fails with "Expecting qubit argument for 'a'". The reporter points at Qasm3SubroutineProcessor.process_quantum_arg, so read how qubit arguments are resolved inside a subroutine's own scope. Done when the recursive program validates without error and the existing subroutine tests still pass.
索引モデルが issue の本文から書いたものです。
説明
Environment
- PyQASM version: 0.3.2
- Python version: 3.12.8
- Operating system: Windows
What happened?
Issue
The OpenQASM standard allows direct recursion by making gate/subroutine identifiers available within their own scope.
However, pyqasm fails when handling recursive calls, producing an unexpected parameter type error.
Example
OPENQASM 3;
include "stdgates.inc";
qubit[5] qb;
bit[5] cb;
const float my_angle = .1;
def test(qubit[1] a,int b){
p(my_angle) a[0];
if(b > 0){
test(a[0],b-1);
}
}
test(qb[2],3);
'''
Observed Behavior
The recursive call throws the following error:
ERROR :pyqasm: Error at line 9, column 2 in QASM file
>>>>>> test(a[0], b - 1)
ValidationError: Expecting qubit argument for 'a'. Qubit register 'a' not found for function 'test'
- note that both test(a,b-1); and test(a[0],b-1); threw the same error when I was testing for semantic errors in my code
Expected Behavior
pyqasm should accept recursive calls in accordance with the OpenQASM standard, correctly resolving subroutine identifiers within their own scope.
Suggestions (Optional)
Id assume this is an error regarding scoping/aliasing within subroutine calls rather than a recursion issue, since error originates from: Qasm3SubroutineProcessor.process_quantum_arg(
- 主要言語
- Python
- スター
- 29
- フォーク
- 33
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 15
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
qBraid/pyqasm のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 63/100
メンテナーはふだん 1 日以内に返信
-
enhancement error-handling program-validation
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 1 日以内に返信
-
Move the QASM 2 printer and its branch pre-processing out of qasm2.py対応中かも @danielgaskins が 7 日前に担当しました。 オープンenhancement qasm2
難易度 4/5 3〜5日 初心者へのやさしさ 22/100
qBraid/pyqasm#447 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] dumps() emits extern calls without a semicolon, producing unparsable QASM対応中かも @Jah-yee が 16 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 25/100
qBraid/pyqasm#438 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Parse failures raise ValidationError with an empty message; the ANTLR diagnostic is lost対応中かも @tonycoder-hub が 9 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 22/100
qBraid/pyqasm#436 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
-
[Bug]: Queen's own Ollama model loses num_ctx when a running session switches to it対応中かも @anasamin26 が今日担当しました。 オープンbug enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
aden-hive/hive#7508 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
llm translation
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
BerriAI/litellm#47884 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
bug 🐛
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
netalertx/NetAlertX#1856 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信