[ruby/prism] Match circular parameter error message

https://github.com/ruby/prism/commit/c0381b10e4
This commit is contained in:
Kevin Newton 2024-04-01 15:44:08 -04:00
Родитель 571bfc7402
Коммит 3147404d64
3 изменённых файлов: 6 добавлений и 7 удалений

Просмотреть файл

@ -4841,7 +4841,7 @@ pm_local_variable_or_write_node_create(pm_parser_t *parser, pm_node_t *target, c
static pm_local_variable_read_node_t *
pm_local_variable_read_node_create_constant_id(pm_parser_t *parser, const pm_token_t *name, pm_constant_id_t name_id, uint32_t depth) {
if (parser->current_param_name == name_id) {
pm_parser_err_token(parser, name, PM_ERR_PARAMETER_CIRCULAR);
PM_PARSER_ERR_TOKEN_FORMAT_CONTENT(parser, *name, PM_ERR_PARAMETER_CIRCULAR);
}
pm_local_variable_read_node_t *node = PM_ALLOC_NODE(parser, pm_local_variable_read_node_t);

Просмотреть файл

@ -251,7 +251,7 @@ static const pm_diagnostic_data_t diagnostic_messages[PM_DIAGNOSTIC_ID_MAX] = {
[PM_ERR_OPERATOR_WRITE_BLOCK] = { "unexpected operator after a call with a block", PM_ERROR_LEVEL_SYNTAX },
[PM_ERR_PARAMETER_ASSOC_SPLAT_MULTI] = { "unexpected multiple `**` splat parameters", PM_ERROR_LEVEL_SYNTAX },
[PM_ERR_PARAMETER_BLOCK_MULTI] = { "multiple block parameters; only one block is allowed", PM_ERROR_LEVEL_SYNTAX },
[PM_ERR_PARAMETER_CIRCULAR] = { "parameter default value references itself", PM_ERROR_LEVEL_SYNTAX },
[PM_ERR_PARAMETER_CIRCULAR] = { "circular argument reference - %.*s", PM_ERROR_LEVEL_SYNTAX },
[PM_ERR_PARAMETER_METHOD_NAME] = { "unexpected name for a parameter", PM_ERROR_LEVEL_SYNTAX },
[PM_ERR_PARAMETER_NAME_DUPLICATED] = { "duplicated argument name", PM_ERROR_LEVEL_SYNTAX },
[PM_ERR_PARAMETER_NO_DEFAULT] = { "expected a default value for the parameter", PM_ERROR_LEVEL_SYNTAX },

Просмотреть файл

@ -1943,12 +1943,11 @@ module Prism
proc { |foo: foo| }
RUBY
message = 'parameter default value references itself'
assert_errors expression(source), source, [
[message, 14..17],
[message, 37..40],
[message, 61..64],
[message, 81..84],
["circular argument reference - bar", 14..17],
["circular argument reference - bar", 37..40],
["circular argument reference - foo", 61..64],
["circular argument reference - foo", 81..84],
]
end