diff --git a/config.yml b/config.yml index b37b98cbdf..f44dc6fa2b 100644 --- a/config.yml +++ b/config.yml @@ -1,5 +1,6 @@ errors: - ALIAS_ARGUMENT + - ALIAS_ARGUMENT_GLOBAL_VARIABLE - ALIAS_ARGUMENT_NUMBERED_REFERENCE - AMPAMPEQ_MULTI_ASSIGN - ARGUMENT_AFTER_BLOCK diff --git a/src/prism.c b/src/prism.c index 8707330c95..ca4e78b225 100644 --- a/src/prism.c +++ b/src/prism.c @@ -18799,7 +18799,7 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power, b pm_parser_err_node(parser, old_name, PM_ERR_ALIAS_ARGUMENT_NUMBERED_REFERENCE); } } else { - pm_parser_err_node(parser, old_name, PM_ERR_ALIAS_ARGUMENT); + pm_parser_err_node(parser, old_name, PM_ERR_ALIAS_ARGUMENT_GLOBAL_VARIABLE); } return (pm_node_t *) pm_alias_global_variable_node_create(parser, &keyword, new_name, old_name); diff --git a/templates/src/diagnostic.c.erb b/templates/src/diagnostic.c.erb index 9a30a57e3b..af01f3e32a 100644 --- a/templates/src/diagnostic.c.erb +++ b/templates/src/diagnostic.c.erb @@ -86,6 +86,7 @@ static const pm_diagnostic_data_t diagnostic_messages[PM_DIAGNOSTIC_ID_MAX] = { // Errors that should raise syntax errors [PM_ERR_ALIAS_ARGUMENT] = { "invalid argument being passed to `alias`; expected a bare word, symbol, constant, or global variable", PM_ERROR_LEVEL_SYNTAX }, + [PM_ERR_ALIAS_ARGUMENT_GLOBAL_VARIABLE] = { "invalid argument being passed to `alias`; when aliasing global variables, both the old and new names must be global variables", PM_ERROR_LEVEL_SYNTAX }, [PM_ERR_ALIAS_ARGUMENT_NUMBERED_REFERENCE] = { "invalid argument being passed to `alias`; can't make alias for the number variables", PM_ERROR_LEVEL_SYNTAX }, [PM_ERR_AMPAMPEQ_MULTI_ASSIGN] = { "unexpected `&&=` in a multiple assignment", PM_ERROR_LEVEL_SYNTAX }, [PM_ERR_ARGUMENT_AFTER_BLOCK] = { "unexpected argument after a block argument", PM_ERROR_LEVEL_SYNTAX }, diff --git a/test/prism/errors/aliasing_global_variable_with_non_global_variable.txt b/test/prism/errors/aliasing_global_variable_with_non_global_variable.txt index b6f013bab5..c956e5fe77 100644 --- a/test/prism/errors/aliasing_global_variable_with_non_global_variable.txt +++ b/test/prism/errors/aliasing_global_variable_with_non_global_variable.txt @@ -1,3 +1,3 @@ alias $a b - ^ invalid argument being passed to `alias`; expected a bare word, symbol, constant, or global variable + ^ invalid argument being passed to `alias`; when aliasing global variables, both the old and new names must be global variables