Skip to content

Commit

Permalink
chore: add regression tests for #4372 (#6401)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench authored Oct 30, 2024
1 parent 713ff22 commit 4e44e1f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
26 changes: 18 additions & 8 deletions compiler/noirc_frontend/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3548,17 +3548,27 @@ fn uses_self_in_import() {
}

#[test]
fn alias_in_let_pattern() {
fn does_not_error_on_return_values_after_block_expression() {
// Regression test for https://github.com/noir-lang/noir/issues/4372
let src = r#"
struct Foo<T> { x: T }
type Bar<U> = Foo<U>;
fn case1() -> [Field] {
if true {
}
&[1]
}
fn main() {
let Bar { x } = Foo { x: [0] };
// This is just to show the compiler knows this is an array.
let _: [Field; 1] = x;
fn case2() -> [u8] {
let mut var: u8 = 1;
{
var += 1;
}
&[var]
}
fn main() {
let _ = case1();
let _ = case2();
}
"#;
assert_no_errors(src);
}
16 changes: 16 additions & 0 deletions compiler/noirc_frontend/src/tests/aliases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,19 @@ fn allows_usage_of_type_alias_as_return_type() {
"#;
assert_no_errors(src);
}

#[test]
fn alias_in_let_pattern() {
let src = r#"
struct Foo<T> { x: T }
type Bar<U> = Foo<U>;
fn main() {
let Bar { x } = Foo { x: [0] };
// This is just to show the compiler knows this is an array.
let _: [Field; 1] = x;
}
"#;
assert_no_errors(src);
}

0 comments on commit 4e44e1f

Please sign in to comment.