diff --git a/src/protocol/tests/parser_validation.rs b/src/protocol/tests/parser_validation.rs index 02f8d7756691d1ba32c0ff764af5f6a0bd3cac4f..0462c7e1e7f81070d022ab9fa36ad21f66d6203c 100644 --- a/src/protocol/tests/parser_validation.rs +++ b/src/protocol/tests/parser_validation.rs @@ -476,6 +476,38 @@ fn test_incorrect_tuple_polymorph_args() { }); } +#[test] +fn test_incorrect_tuple_member_access() { + Tester::new_single_source_expect_err( + "zero-tuple", + "func foo() -> () { () a = (); auto b = a.0; return a; }" + ).error(|e| { e + .assert_num(1) + .assert_msg_has(0, "out of bounds") + .assert_occurs_at(0, "a.0"); + }); + + // Make the type checker do some shenanigans before we can decide the tuple + // type. + Tester::new_single_source_expect_err( + "sized tuple", + " + func determinator((A,B,A) v) -> B { return v.1; } + func tester() -> u64 { + auto v = (0,1,2); + u32 a_u32 = 5; + v.2 = a_u32; + v.8 = 5; + return determinator(v); + } + " + ).error(|e| { e + .assert_num(1) + .assert_msg_has(0, "out of bounds") + .assert_occurs_at(0, "v.8"); + }); +} + #[test] fn test_polymorph_array_types() { Tester::new_single_source_expect_ok(