diff options
| author | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-01-09 22:49:32 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-01-09 22:49:32 +0100 |
| commit | 68ce788d00fe0b8353b7e6aee5ce8dfae564ea5a (patch) | |
| tree | 107cfc607347bfdc6d29aff6e1c445077f9709e7 /lib/xixanta/src | |
| parent | ec0831e82851862a6af2ade12a996634d5dfc64e (diff) | |
| download | tools.nes-68ce788d00fe0b8353b7e6aee5ce8dfae564ea5a.tar.gz tools.nes-68ce788d00fe0b8353b7e6aee5ce8dfae564ea5a.zip | |
Improve error message on unknown variable/scope
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'lib/xixanta/src')
| -rw-r--r-- | lib/xixanta/src/assembler.rs | 18 | ||||
| -rw-r--r-- | lib/xixanta/src/object.rs | 2 |
2 files changed, 9 insertions, 11 deletions
diff --git a/lib/xixanta/src/assembler.rs b/lib/xixanta/src/assembler.rs index 1f7c9a5..f190d33 100644 --- a/lib/xixanta/src/assembler.rs +++ b/lib/xixanta/src/assembler.rs @@ -791,10 +791,7 @@ impl<'a> Assembler<'a> { Ok(v) } Err(err) => Err(Error { - message: format!( - "no prefix was given to operand and {} either", - err.message - ), + message: err.message, line: node.value.line, source: self.source_for(node), global: false, @@ -2239,15 +2236,16 @@ mod tests { #[test] fn bad_variable_but_valid_identifier_in_instruction() { assert_error( - "adc Variable", - 1, false, - "no prefix was given to operand and could not find variable 'Variable' in the global scope either", - ); + "adc Variable", + 1, + false, + "could not find variable 'Variable' in the global scope", + ); assert_error( "adc Scoped::Variable", 1, false, - "no prefix was given to operand and did not find scope 'Scoped' either", + "could not find scope 'Scoped'", ); } @@ -2292,7 +2290,7 @@ mod tests { "lda #Scope::Variable", 1, false, - "'e' is not a decimal value and did not find scope 'Scope' either", + "'e' is not a decimal value and could not find scope 'Scope' either", ); assert_error( r#" diff --git a/lib/xixanta/src/object.rs b/lib/xixanta/src/object.rs index 77ab8a6..ad02747 100644 --- a/lib/xixanta/src/object.rs +++ b/lib/xixanta/src/object.rs @@ -232,7 +232,7 @@ impl Context { } } }, - None => Err(format!("did not find scope '{}'", scope_name)), + None => Err(format!("could not find scope '{}'", scope_name)), } } |
