Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
errors:
- ALIAS_ARGUMENT
- ALIAS_ARGUMENT_GLOBAL_VARIABLE
- ALIAS_ARGUMENT_NUMBERED_REFERENCE
- AMPAMPEQ_MULTI_ASSIGN
- ARGUMENT_AFTER_BLOCK
Expand Down
2 changes: 1 addition & 1 deletion src/prism.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions templates/src/diagnostic.c.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the message can be more specific. Since this error only happens when the first (new) name is already a global variable, we can probably say

invalid argument being passed to `alias`; expected the old name to be a global variable as well

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

old name might be unclear if it's the first or second argument (alias is notoriously confusing about this), so I'd suggest to use the second name instead of the old name, or the message in the current state of this PR (which sounds clear to me).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's fair. My point is mostly that the message can be more concise. the second name indeed works better.

[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 },
Expand Down
Original file line number Diff line number Diff line change
@@ -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