diff --git a/CHANGELOG.md b/CHANGELOG.md index 360524c..6dd5d7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 0.7.1 (unreleased) + +### Bugfixes +* Trying to invoke an undefined macro correctly did not report the macro as undefined ([#195](https://github.com/datatrash/mos/issues/195)) + ## 0.7.0 (2021-06-18) ### New features diff --git a/mos-core/src/codegen/mod.rs b/mos-core/src/codegen/mod.rs index 536bc69..a93924c 100644 --- a/mos-core/src/codegen/mod.rs +++ b/mos-core/src/codegen/mod.rs @@ -1018,6 +1018,12 @@ impl CodegenContext { Ok(()) })?; + } else { + self.undefined.insert(UndefinedSymbol { + scope_nx: self.current_scope_nx, + id: name.data.clone().into(), + span: Some(name.span), + }); } } Token::ProgramCounterDefinition { value, .. } => { @@ -2096,6 +2102,16 @@ pub mod tests { Ok(()) } + #[test] + fn cannot_use_unknown_macros() -> CoreResult<()> { + let err = test_codegen("foo(1)").err().unwrap(); + assert_eq!( + err.to_string(), + "test.asm:1:1: error: unknown identifier: foo" + ); + Ok(()) + } + #[test] fn can_invoke_uninvoked_macros() -> CoreResult<()> { let ctx = test_codegen_with_options(