diff --git a/compiler/qsc_frontend/src/lower/tests.rs b/compiler/qsc_frontend/src/lower/tests.rs index 91eb19df67..e444700b5a 100644 --- a/compiler/qsc_frontend/src/lower/tests.rs +++ b/compiler/qsc_frontend/src/lower/tests.rs @@ -2189,3 +2189,29 @@ fn duplicate_commas_in_arg_tuple() { ctl-adj: "#]], ); } + +#[test] +fn ignore_item_in_attribute() { + check_hir( + "namespace Test { + @Attr{function Bar() : Unit { Bar }} + function Foo() : Unit {} + }", + &expect![[r#" + Package: + Item 0 [0-112] (Public): + Namespace (Ident 5 [10-14] "Test"): Item 1 + Item 1 [29-102] (Public): + Parent: 0 + Callable 0 [78-102] (function): + name: Ident 1 [87-90] "Foo" + input: Pat 2 [90-92] [Type Unit]: Unit + output: Unit + functors: empty set + body: SpecDecl 3 [78-102]: Impl: + Block 4 [100-102]: + adj: + ctl: + ctl-adj: "#]], + ); +} diff --git a/compiler/qsc_frontend/src/typeck/check.rs b/compiler/qsc_frontend/src/typeck/check.rs index 8f10f65c3b..5547b8fabe 100644 --- a/compiler/qsc_frontend/src/typeck/check.rs +++ b/compiler/qsc_frontend/src/typeck/check.rs @@ -266,4 +266,7 @@ impl Visitor<'_> for ItemChecker<'_> { self.checker.check_callable_decl(self.names, decl); visit::walk_callable_decl(self, decl); } + + // We do not typecheck attributes, as they are verified during lowering. + fn visit_attr(&mut self, _: &ast::Attr) {} } diff --git a/compiler/qsc_parse/src/item/tests.rs b/compiler/qsc_parse/src/item/tests.rs index a83a4692f7..42049db4f2 100644 --- a/compiler/qsc_parse/src/item/tests.rs +++ b/compiler/qsc_parse/src/item/tests.rs @@ -1318,6 +1318,7 @@ fn callable_missing_parens() { ]"#]], ) } + #[test] fn callable_missing_close_parens() { check_vec( @@ -1346,6 +1347,7 @@ fn callable_missing_close_parens() { ]"#]], ) } + #[test] fn callable_missing_open_parens() { check_vec(