diff --git a/dora-frontend/src/typeck/tests.rs b/dora-frontend/src/typeck/tests.rs index db4d4a0d2..f5e8c7583 100644 --- a/dora-frontend/src/typeck/tests.rs +++ b/dora-frontend/src/typeck/tests.rs @@ -4793,6 +4793,31 @@ fn unnamed_class_field() { ); } +#[test] +fn unnamed_access_on_named_field() { + err( + " + class Foo { a: Int, b: Bool } + fn f(x: Foo): Int { + x.0 + } + ", + (4, 15), + ErrorMessage::UnknownField("0".into(), "Foo".into()), + ); + + err( + " + struct Foo { a: Int, b: Bool } + fn f(x: Foo): Int { + x.0 + } + ", + (4, 15), + ErrorMessage::UnknownField("0".into(), "Foo".into()), + ); +} + #[test] fn unnamed_struct_field() { ok("