Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test to reproduce #2051 #2055

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions pilopt/tests/optimizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,3 +281,24 @@ fn enum_ref_by_trait() {
let optimized = optimize(analyze_string::<GoldilocksField>(input).unwrap()).to_string();
assert_eq!(optimized, expectation);
}

#[test]
#[should_panic = "Symbol not found: N::x[0]"]
fn handle_array_references_in_prover_functions() {
// Reproduces https://github.com/powdr-labs/powdr/issues/2051
let input = r#"namespace N(8);
col witness x[1];

// non-trivial constraint so that `x[0]` does not get removed.
x[0]' = x[0] + 1;

{
let intermediate = x[0] + 1;
query |i| {
// No-op, but references `x[0]`.
let _ = intermediate;
}
};
Comment on lines +295 to +301
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the block is in-lined the bug goes away. Not sure what difference it makes?

"#;
optimize(analyze_string::<GoldilocksField>(input).unwrap()).to_string();
}