diff --git a/crates/analyzer/tests/errors.rs b/crates/analyzer/tests/errors.rs index 00d5793db3..c4466e59fc 100644 --- a/crates/analyzer/tests/errors.rs +++ b/crates/analyzer/tests/errors.rs @@ -341,3 +341,4 @@ test_file! { ctx_builtins_param_incorrect_type } test_file! { ctx_undefined_create } test_file! { ctx_undefined_create2 } test_file! { ctx_undefined_event } +test_file! { uninit_values } diff --git a/crates/analyzer/tests/snapshots/errors__uninit_values.snap b/crates/analyzer/tests/snapshots/errors__uninit_values.snap new file mode 100644 index 0000000000..89c96c82eb --- /dev/null +++ b/crates/analyzer/tests/snapshots/errors__uninit_values.snap @@ -0,0 +1,18 @@ +--- +source: crates/analyzer/tests/errors.rs +expression: "error_string(&path, test_files::fixture(path))" + +--- +error: uninitialized variable + ┌─ compile_errors/uninit_values.fe:7:13 + │ +7 │ let my_struct: MyStruct + │ ^^^^^^^^^ uninitialized variable + +error: uninitialized variable + ┌─ compile_errors/uninit_values.fe:8:13 + │ +8 │ let my_array: Array + │ ^^^^^^^^ uninitialized variable + + diff --git a/crates/test-files/fixtures/compile_errors/uninit_values.fe b/crates/test-files/fixtures/compile_errors/uninit_values.fe new file mode 100644 index 0000000000..2aded6d81f --- /dev/null +++ b/crates/test-files/fixtures/compile_errors/uninit_values.fe @@ -0,0 +1,10 @@ +struct MyStruct { + x: u256 +} + +contract Foo { + pub fn foo() { + let my_struct: MyStruct + let my_array: Array + } +} \ No newline at end of file diff --git a/crates/test-files/fixtures/features/array_repeat.fe b/crates/test-files/fixtures/features/array_repeat.fe new file mode 100644 index 0000000000..6222b5c974 --- /dev/null +++ b/crates/test-files/fixtures/features/array_repeat.fe @@ -0,0 +1,7 @@ +contract Foo { + pub fn foo() -> Array { + let my_array: Array = [8; 4] + my_array[1] = 42 + return my_array + } +} \ No newline at end of file diff --git a/crates/tests/src/features.rs b/crates/tests/src/features.rs index 1113fc50c2..fcd1efc1d6 100644 --- a/crates/tests/src/features.rs +++ b/crates/tests/src/features.rs @@ -2072,3 +2072,11 @@ fn generics() { harness.test_function(&mut executor, "generic_compute", &[], None); }); } + +#[test] +fn array_repeat() { + with_executor(&|mut executor| { + let harness = deploy_contract(&mut executor, "array_repeat.fe", "Foo", &[]); + harness.test_function(&mut executor, "foo", &[], Some(&uint_array_token(&[8, 42, 8, 8]))); + }); +}