Skip to content

Commit

Permalink
Improve error message on unknown variable/scope
Browse files Browse the repository at this point in the history
Signed-off-by: Miquel Sabaté Solà <[email protected]>
  • Loading branch information
mssola committed Jan 9, 2025
1 parent ec0831e commit 68ce788
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
18 changes: 8 additions & 10 deletions lib/xixanta/src/assembler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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'",
);
}

Expand Down Expand Up @@ -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#"
Expand Down
2 changes: 1 addition & 1 deletion lib/xixanta/src/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ impl Context {
}
}
},
None => Err(format!("did not find scope '{}'", scope_name)),
None => Err(format!("could not find scope '{}'", scope_name)),
}
}

Expand Down

0 comments on commit 68ce788

Please sign in to comment.