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 29, 2024
1 parent 9a34571 commit 3b23ca5
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 14 deletions.
22 changes: 13 additions & 9 deletions external-crates/move/crates/move-compiler/src/naming/translate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2517,24 +2517,28 @@ fn exp(context: &mut Context, e: Box<E::Exp>) -> Box<N::Exp> {
}
// If this variable refers to a local (num > 0) or it isn't syntax, error.
if !v.value.is_syntax_identifier() {
let name = v.value.name;
let msg = format!(
"Unexpected invocation of parameter or local '{}'. \
Non-syntax variables cannot be invoked as functions.",
v.value.name
"Unexpected invocation of parameter or local '{name}'. \
Non-syntax variables cannot be invoked as functions",
);
let note = format!(
"Only macro syntax variables, e.g. '${name}', \
may be invoked as functions."
);
let mut diag = diag!(TypeSafety::InvalidCallTarget, (v.loc, msg));
diag.add_note(note);
context
.env
.add_diag(diag!(TypeSafety::InvalidCallTarget, (v.loc, msg)));
.add_diag(diag);
NE::UnresolvedError
} else if v.value.id != 0 {
let name = v.value.name;
let msg = format!(
"Unexpected invocation of non-parameter variable '{}'. \
"Unexpected invocation of non-parameter variable '{name}'. \
Only lambda-typed syntax parameters may be invoked",
v.value.name
);
context
.env
.add_diag(diag!(TypeSafety::InvalidCallTarget, (v.loc, msg)));
context.env.add_diag(diag!(TypeSafety::InvalidCallTarget, (v.loc, msg)));
NE::UnresolvedError
} else {
NE::VarCall(v, nes)
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 3b23ca5

Please sign in to comment.