From cf8ccfbca2ccd901101121537e349a28414d3432 Mon Sep 17 00:00:00 2001 From: Michael Klein Date: Fri, 7 Mar 2025 16:52:06 -0500 Subject: [PATCH] chore: add regression tests for PR #7570 from lambda interpreter test --- .../regression_7570_nested/Nargo.toml | 6 ++++ .../regression_7570_nested/src/main.nr | 30 +++++++++++++++++++ .../regression_7570_serial/Nargo.toml | 6 ++++ .../regression_7570_serial/src/main.nr | 27 +++++++++++++++++ 4 files changed, 69 insertions(+) create mode 100644 test_programs/compile_success_empty/regression_7570_nested/Nargo.toml create mode 100644 test_programs/compile_success_empty/regression_7570_nested/src/main.nr create mode 100644 test_programs/compile_success_empty/regression_7570_serial/Nargo.toml create mode 100644 test_programs/compile_success_empty/regression_7570_serial/src/main.nr diff --git a/test_programs/compile_success_empty/regression_7570_nested/Nargo.toml b/test_programs/compile_success_empty/regression_7570_nested/Nargo.toml new file mode 100644 index 00000000000..ff20220f2a3 --- /dev/null +++ b/test_programs/compile_success_empty/regression_7570_nested/Nargo.toml @@ -0,0 +1,6 @@ +[package] +name = "regression_7570_nested" +type = "bin" +authors = [""] + +[dependencies] diff --git a/test_programs/compile_success_empty/regression_7570_nested/src/main.nr b/test_programs/compile_success_empty/regression_7570_nested/src/main.nr new file mode 100644 index 00000000000..f1669330257 --- /dev/null +++ b/test_programs/compile_success_empty/regression_7570_nested/src/main.nr @@ -0,0 +1,30 @@ +// Regression test for bug that appears to be fixed by https://github.com/noir-lang/noir/pull/7570 +pub enum Foo { + // at least three variants are required, i.e. + // if e.g. only `A` and `B` are included, the bug goes away + A, + B, + C, +} + +fn main() { + // - the error occured with or without values in the array + // - the error goes away if `x` is directly defined as e.g. `Foo::A` + let arena: [Foo; 1] = [Foo::A]; + let x = arena[0]; + + // this needs to be in a loop with a positive bound for the error to occur + for _ in 0..1 { + match x { + Foo::A => { + // the error goes away if this match is removed + match x { + // the error goes away if we only match on Foo::A and/or '_' + Foo::B => (), + _ => (), + } + }, + _ => (), + } + } +} diff --git a/test_programs/compile_success_empty/regression_7570_serial/Nargo.toml b/test_programs/compile_success_empty/regression_7570_serial/Nargo.toml new file mode 100644 index 00000000000..149962e252d --- /dev/null +++ b/test_programs/compile_success_empty/regression_7570_serial/Nargo.toml @@ -0,0 +1,6 @@ +[package] +name = "regression_7570_serial" +type = "bin" +authors = [""] + +[dependencies] diff --git a/test_programs/compile_success_empty/regression_7570_serial/src/main.nr b/test_programs/compile_success_empty/regression_7570_serial/src/main.nr new file mode 100644 index 00000000000..6182f44149f --- /dev/null +++ b/test_programs/compile_success_empty/regression_7570_serial/src/main.nr @@ -0,0 +1,27 @@ +// Regression test for bug that appears to be fixed by https://github.com/noir-lang/noir/pull/7570 +pub enum Foo { + // at least three variants are required, i.e. + // if e.g. only `A` and `B` are included, the bug goes away + A, + B, + C, +} + +fn main() { + // - the error occurs with or without values in the array + // - the error goes away if `x` is directly defined as e.g. `Foo::A` + let arena: [Foo; 1] = [Foo::A]; + let x = arena[0]; + + match x { + Foo::A => (), + _ => (), + } + + // the error goes away if this match is removed + match x { + // the error goes away if we only match on Foo::A and/or '_' + Foo::B => (), + _ => (), + } +}