From 80bb607597138977d2f6162cae59038b1e67c2a5 Mon Sep 17 00:00:00 2001 From: vezenovm Date: Thu, 2 May 2024 22:09:04 +0000 Subject: [PATCH 1/3] switch to annotated_type in check_declaration --- .../noirc_frontend/src/hir/type_check/stmt.rs | 4 +++- .../slice_init_with_complex_type/Nargo.toml | 7 +++++++ .../slice_init_with_complex_type/Prover.toml | 0 .../slice_init_with_complex_type/src/main.nr | 20 +++++++++++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 test_programs/execution_success/slice_init_with_complex_type/Nargo.toml create mode 100644 test_programs/execution_success/slice_init_with_complex_type/Prover.toml create mode 100644 test_programs/execution_success/slice_init_with_complex_type/src/main.nr diff --git a/compiler/noirc_frontend/src/hir/type_check/stmt.rs b/compiler/noirc_frontend/src/hir/type_check/stmt.rs index f5f6e1e8180..0760749c9e0 100644 --- a/compiler/noirc_frontend/src/hir/type_check/stmt.rs +++ b/compiler/noirc_frontend/src/hir/type_check/stmt.rs @@ -348,8 +348,10 @@ impl<'interner> TypeChecker<'interner> { if annotated_type.is_unsigned() { self.lint_overflowing_uint(&rhs_expr, &annotated_type); } + annotated_type + } else { + expr_type } - expr_type } /// Check if an assignment is overflowing with respect to `annotated_type` diff --git a/test_programs/execution_success/slice_init_with_complex_type/Nargo.toml b/test_programs/execution_success/slice_init_with_complex_type/Nargo.toml new file mode 100644 index 00000000000..a372caf92e9 --- /dev/null +++ b/test_programs/execution_success/slice_init_with_complex_type/Nargo.toml @@ -0,0 +1,7 @@ +[package] +name = "slice_init_with_complex_type" +type = "bin" +authors = [""] +compiler_version = ">=0.28.0" + +[dependencies] \ No newline at end of file diff --git a/test_programs/execution_success/slice_init_with_complex_type/Prover.toml b/test_programs/execution_success/slice_init_with_complex_type/Prover.toml new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test_programs/execution_success/slice_init_with_complex_type/src/main.nr b/test_programs/execution_success/slice_init_with_complex_type/src/main.nr new file mode 100644 index 00000000000..1b61d32b52d --- /dev/null +++ b/test_programs/execution_success/slice_init_with_complex_type/src/main.nr @@ -0,0 +1,20 @@ +struct strct1 { + elem1: Field, +} + +fn main() { + /* Panic when you initialize a slice of arrays with a value of a slice with the exact same type */ + let var1: [[i32; 1]] = [[0]]; + let var2: [[i32; 1]] = var1; + + /* Still panics with other composite types */ + let var1: [(i32, u8)] = [(1, 2)]; + let var2: [(i32, u8)] = var1; + + let var3: [strct1] = [strct1 { elem1: 1321351 }]; + let var4: [strct1] = var3; + + /* No panic if the slice is created in this initialization sentence, even with an existing array */ + let var1: [i32; 1] = [0]; + let var2: [[i32; 1]] = [var1]; +} From 2b70ad32af06178da413861ab3098005198ead19 Mon Sep 17 00:00:00 2001 From: vezenovm Date: Thu, 2 May 2024 22:10:15 +0000 Subject: [PATCH 2/3] remove comments --- .../execution_success/slice_init_with_complex_type/src/main.nr | 3 --- 1 file changed, 3 deletions(-) diff --git a/test_programs/execution_success/slice_init_with_complex_type/src/main.nr b/test_programs/execution_success/slice_init_with_complex_type/src/main.nr index 1b61d32b52d..01ccf2fdeff 100644 --- a/test_programs/execution_success/slice_init_with_complex_type/src/main.nr +++ b/test_programs/execution_success/slice_init_with_complex_type/src/main.nr @@ -3,18 +3,15 @@ struct strct1 { } fn main() { - /* Panic when you initialize a slice of arrays with a value of a slice with the exact same type */ let var1: [[i32; 1]] = [[0]]; let var2: [[i32; 1]] = var1; - /* Still panics with other composite types */ let var1: [(i32, u8)] = [(1, 2)]; let var2: [(i32, u8)] = var1; let var3: [strct1] = [strct1 { elem1: 1321351 }]; let var4: [strct1] = var3; - /* No panic if the slice is created in this initialization sentence, even with an existing array */ let var1: [i32; 1] = [0]; let var2: [[i32; 1]] = [var1]; } From 8a3a1a67a39bdfbb01355b0c128c1b8ed9b80d9c Mon Sep 17 00:00:00 2001 From: vezenovm Date: Thu, 2 May 2024 22:24:28 +0000 Subject: [PATCH 3/3] ignore slice_init_with_complex_type in debugger --- tooling/debugger/ignored-tests.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tooling/debugger/ignored-tests.txt b/tooling/debugger/ignored-tests.txt index f2338e85bef..fccf4566258 100644 --- a/tooling/debugger/ignored-tests.txt +++ b/tooling/debugger/ignored-tests.txt @@ -22,4 +22,5 @@ no_predicates_numeric_generic_poseidon regression_4709 fold_distinct_return fold_fibonacci -fold_complex_outputs \ No newline at end of file +fold_complex_outputs +slice_init_with_complex_type \ No newline at end of file