Improve diagnostic

This commit is contained in:
Andrew Morris
2023-03-24 10:55:08 +11:00
parent f878dbbae9
commit fe2e281d0b
2 changed files with 10 additions and 3 deletions

View File

@@ -320,7 +320,14 @@ impl<'a> ExpressionCompiler<'a> {
fn get_register_for_ident_mutation(&mut self, ident: &swc_ecma_ast::Ident) -> Register {
let (reg, err_msg) = match self.fnc.lookup(ident) {
Some(Value::Register(reg)) => (Some(reg), None),
_ => (None, Some("Invalid: non-register mutation")),
lookup_result => (
None,
Some(format!(
"Invalid: Can't mutate {} because its lookup result is {:?}",
ident.sym.to_string(),
lookup_result,
)),
),
};
if let Some(err_msg) = err_msg {