Skip to content

Commit

Permalink
frontend: Add tests for unnamed field access
Browse files Browse the repository at this point in the history
  • Loading branch information
dinfuehr committed Nov 1, 2024
1 parent e02e2ad commit b1d3d24
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions dora-frontend/src/typeck/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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("
Expand Down

0 comments on commit b1d3d24

Please sign in to comment.