Skip to content

Commit

Permalink
Unknown macro should trigger 'undefined symbol' error. Closes #195.
Browse files Browse the repository at this point in the history
  • Loading branch information
sagacity committed Jul 1, 2021
1 parent f8280f5 commit ee54c2e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
16 changes: 16 additions & 0 deletions mos-core/src/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, .. } => {
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit ee54c2e

Please sign in to comment.