Skip to content

Commit

Permalink
Add note to error
Browse files Browse the repository at this point in the history
  • Loading branch information
cgswords committed May 30, 2024
1 parent f8379c9 commit 53420aa
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 11 deletions.
16 changes: 10 additions & 6 deletions external-crates/move/crates/move-compiler/src/naming/translate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3974,14 +3974,18 @@ fn resolve_call(
}
// If this variable refers to a local (num > 0) or it isn't syntax, error.
if !var.value.is_syntax_identifier() {
let name = var.value.name;
let msg = format!(
"Unexpected invocation of parameter or local '{}'. \
Non-syntax variables cannot be invoked as functions.",
var.value.name
"Unexpected invocation of parameter or local '{name}'. \
Non-syntax variables cannot be invoked as functions",
);
context
.env
.add_diag(diag!(TypeSafety::InvalidCallTarget, (var.loc, msg)));
let note = format!(
"Only macro syntax variables, e.g. '${name}', \
may be invoked as functions."
);
let mut diag = diag!(TypeSafety::InvalidCallTarget, (var.loc, msg));
diag.add_note(note);
context.env.add_diag(diag);
N::Exp_::UnresolvedError
} else if var.value.id != 0 {
let msg = format!(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,7 @@ error[E04029]: invalid function call
┌─ tests/move_2024/expansion/macro_identifier_missing.move:3:9
3 │ f(x)
│ ^ Unexpected invocation of parameter or local 'f'. Non-syntax variables cannot be invoked as functions.
│ ^ Unexpected invocation of parameter or local 'f'. Non-syntax variables cannot be invoked as functions
= Only macro syntax variables, e.g. '$f', may be invoked as functions.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ error[E04029]: invalid function call
┌─ tests/move_2024/naming/macro_parameter_assignment.move:5:9
5 │ f(x)
│ ^ Unexpected invocation of parameter or local 'f'. Non-syntax variables cannot be invoked as functions.
│ ^ Unexpected invocation of parameter or local 'f'. Non-syntax variables cannot be invoked as functions
= Only macro syntax variables, e.g. '$f', may be invoked as functions.

warning[W09005]: dead or unreachable code
┌─ tests/move_2024/naming/macro_parameter_assignment.move:10:15
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ error[E04029]: invalid function call
┌─ tests/move_2024/naming/var_as_fun_invalid.move:4:9
4 │ var();
│ ^^^ Unexpected invocation of parameter or local 'var'. Non-syntax variables cannot be invoked as functions.
│ ^^^ Unexpected invocation of parameter or local 'var'. Non-syntax variables cannot be invoked as functions
= Only macro syntax variables, e.g. '$var', may be invoked as functions.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ error[E04029]: invalid function call
┌─ tests/move_2024/typing/use_lambda_outside_call_invalid.move:4:9
4 │ x();
│ ^ Unexpected invocation of parameter or local 'x'. Non-syntax variables cannot be invoked as functions.
│ ^ Unexpected invocation of parameter or local 'x'. Non-syntax variables cannot be invoked as functions
= Only macro syntax variables, e.g. '$x', may be invoked as functions.

error[E02010]: invalid name
┌─ tests/move_2024/typing/use_lambda_outside_call_invalid.move:7:23
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ error[E04029]: invalid function call
┌─ tests/move_check/naming/var_as_fun_invalid.move:4:9
4 │ var();
│ ^^^ Unexpected invocation of parameter or local 'var'. Non-syntax variables cannot be invoked as functions.
│ ^^^ Unexpected invocation of parameter or local 'var'. Non-syntax variables cannot be invoked as functions
= Only macro syntax variables, e.g. '$var', may be invoked as functions.

error[E13001]: feature is not supported in specified edition
┌─ tests/move_check/naming/var_as_fun_invalid.move:4:9
Expand Down

0 comments on commit 53420aa

Please sign in to comment.