Skip to content

Commit f2824c1

Browse files
authored
call stacks should get captured if group_by_scope=true (#2803)
The `group_by_scope` setting wasn't working when passed in from Python because it by itself wasn't enough to switch on stack trace capturing.
1 parent d0df178 commit f2824c1

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

source/compiler/qsc/src/interpret/circuit_tests.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,43 @@ fn rotation_gate() {
188188
.assert_eq(&circ);
189189
}
190190

191+
#[test]
192+
fn grouping_nested_callables() {
193+
let circ = circuit_with_options(
194+
r"
195+
namespace Test {
196+
@EntryPoint()
197+
operation Main() : Unit {
198+
use q = Qubit();
199+
for i in 0..5 {
200+
Foo(q);
201+
}
202+
MResetZ(q);
203+
}
204+
205+
operation Foo(q: Qubit) : Unit {
206+
H(q);
207+
}
208+
}
209+
",
210+
Profile::Unrestricted,
211+
CircuitEntryPoint::EntryPoint,
212+
CircuitGenerationMethod::ClassicalEval,
213+
TracerConfig {
214+
max_operations: usize::MAX,
215+
source_locations: false,
216+
group_by_scope: true,
217+
},
218+
)
219+
.expect("circuit generation should succeed");
220+
221+
expect![[r#"
222+
q_0 ─ [ [Main] ─── [ [Foo] ─── H ──── H ──── H ──── H ──── H ──── H ──── ] ──── M ──── |0〉 ──── ] ──
223+
[ ╘══════════════ ] ══
224+
"#]]
225+
.assert_eq(&circ.display_with_groups().to_string());
226+
}
227+
191228
#[test]
192229
fn classical_for_loop() {
193230
let circ = circuit(

source/compiler/qsc_circuit/src/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ impl Tracer for CircuitTracer {
134134
}
135135

136136
fn is_stack_tracing_enabled(&self) -> bool {
137-
self.config.source_locations
137+
self.config.source_locations || self.config.group_by_scope
138138
}
139139
}
140140

0 commit comments

Comments
 (0)