Summary
On the latest amazon-braket-default-simulator (1.39.5), a valid OpenQASM 3 program crashes with an
internal AttributeError: 'FloatLiteral' object has no attribute 'name' when it combines a classical
scalar variable with a measurement-dependent if. The program parses cleanly (see Validity below); the
crash happens during execution.
Reproduction (crashes)
from braket.devices import LocalSimulator
from braket.ir.openqasm import Program
qasm = """
OPENQASM 3;
include "stdgates.inc";
qubit[1] q;
bit c;
float a = 3.14159265;
c = measure q[0];
if (c == false) { }
rx(a) q[0];
"""
LocalSimulator().run(Program(source=qasm), shots=10).result()
AttributeError: 'FloatLiteral' object has no attribute 'name'
It runs fine without the classical variable
Dropping float a and using a literal angle -- rx(3.14159265) q[0]; -- runs fine, as does removing the
if. The crash needs both a classical scalar variable and a measurement-conditioned branch. It is
not specific to angles: int a = 3; c = measure q[0]; if (c == false) { } x q[0]; crashes the same way
('IntegerLiteral' object has no attribute 'name') -- an unused scalar + a measurement branch + any
following gate is enough. (angle gives 'SymbolLiteral' object has no attribute 'name'.)
Validity (this is a valid program, not a syntax error)
The program parses cleanly with both the reference parser and Braket's own parser, so this is not a
malformed-input rejection:
import openqasm3
openqasm3.parse(qasm) # OK: 7-statement Program AST, round-trips
from braket.default_simulator.openqasm import interpreter
interpreter.parse(qasm) # OK: Program AST, 7 statements
The AttributeError is raised later, during execution (the interpreter visit), not at parse time.
Traceback (key frames)
.../braket/default_simulator/openqasm/interpreter.py", line 452, in _
[self.context.qubit_mapping.get_qubit_size(qubit) for qubit in qubits]
.../braket/default_simulator/openqasm/program_context.py", line 184, in get_qubit_size
return len(self.get_by_identifier(identifier))
.../braket/default_simulator/openqasm/program_context.py", line 140, in get_by_identifier
if identifier.name.startswith("$"):
AttributeError: 'FloatLiteral' object has no attribute 'name'
On the measurement-branched execution path, the gate's qubit resolution appears to receive the classical
value (a FloatLiteral / IntegerLiteral / SymbolLiteral) where a qubit Identifier is expected.
Expected
The program should simulate. A classical variable together with a measurement-conditioned if is valid
OpenQASM 3, so it should not raise an internal AttributeError.
Environment
amazon-braket-default-simulator 1.39.5 (latest on PyPI, 2026-06-22)
amazon-braket-sdk 1.121.0 - amazon-braket-schemas 1.31.0 - openqasm3 1.0.1 - antlr4-python3-runtime 4.13.2
- Python 3.12.9 - Windows 11 - device:
LocalSimulator() (StateVectorSimulator)
Summary
On the latest
amazon-braket-default-simulator(1.39.5), a valid OpenQASM 3 program crashes with aninternal
AttributeError: 'FloatLiteral' object has no attribute 'name'when it combines a classicalscalar variable with a measurement-dependent
if. The program parses cleanly (see Validity below); thecrash happens during execution.
Reproduction (crashes)
It runs fine without the classical variable
Dropping
float aand using a literal angle --rx(3.14159265) q[0];-- runs fine, as does removing theif. The crash needs both a classical scalar variable and a measurement-conditioned branch. It isnot specific to angles:
int a = 3; c = measure q[0]; if (c == false) { } x q[0];crashes the same way(
'IntegerLiteral' object has no attribute 'name') -- an unused scalar + a measurement branch + anyfollowing gate is enough. (
anglegives'SymbolLiteral' object has no attribute 'name'.)Validity (this is a valid program, not a syntax error)
The program parses cleanly with both the reference parser and Braket's own parser, so this is not a
malformed-input rejection:
The
AttributeErroris raised later, during execution (the interpreter visit), not at parse time.Traceback (key frames)
On the measurement-branched execution path, the gate's qubit resolution appears to receive the classical
value (a
FloatLiteral/IntegerLiteral/SymbolLiteral) where a qubitIdentifieris expected.Expected
The program should simulate. A classical variable together with a measurement-conditioned
ifis validOpenQASM 3, so it should not raise an internal
AttributeError.Environment
amazon-braket-default-simulator1.39.5 (latest on PyPI, 2026-06-22)amazon-braket-sdk1.121.0 -amazon-braket-schemas1.31.0 -openqasm31.0.1 -antlr4-python3-runtime4.13.2LocalSimulator()(StateVectorSimulator)