зеркало из https://github.com/github/ruby.git
[ruby/prism] Use `0` for the default valie of `current_param_name`
https://github.com/ruby/prism/commit/896915de24
This commit is contained in:
Родитель
b5796d7b11
Коммит
f6fbb9fec5
|
@ -675,11 +675,7 @@ struct pm_parser {
|
|||
/** This flag indicates that we are currently parsing a keyword argument. */
|
||||
bool in_keyword_arg;
|
||||
|
||||
/**
|
||||
* The current parameter name id on parsing its default value.
|
||||
* Since this is used for detecting circular references, this is available
|
||||
* only on `PM_CONTEXT_DEFAULT_PARAM`.
|
||||
*/
|
||||
/** The current parameter name id on parsing its default value. */
|
||||
pm_constant_id_t current_param_name;
|
||||
|
||||
/**
|
||||
|
|
|
@ -4040,8 +4040,6 @@ pm_local_variable_or_write_node_create(pm_parser_t *parser, pm_node_t *target, c
|
|||
return node;
|
||||
}
|
||||
|
||||
static bool context_p(pm_parser_t *parser, pm_context_t context);
|
||||
|
||||
/**
|
||||
* Allocate a new LocalVariableReadNode node.
|
||||
*/
|
||||
|
@ -4049,10 +4047,7 @@ static pm_local_variable_read_node_t *
|
|||
pm_local_variable_read_node_create(pm_parser_t *parser, const pm_token_t *name, uint32_t depth) {
|
||||
pm_constant_id_t name_id = pm_parser_constant_id_token(parser, name);
|
||||
|
||||
if (
|
||||
context_p(parser, PM_CONTEXT_DEFAULT_PARAMS) &&
|
||||
parser->current_param_name == name_id
|
||||
) {
|
||||
if (parser->current_param_name == name_id) {
|
||||
pm_parser_err_token(parser, name, PM_ERR_PARAMETER_CIRCULAR);
|
||||
}
|
||||
|
||||
|
@ -16958,6 +16953,7 @@ pm_parser_init(pm_parser_t *parser, const uint8_t *source, size_t size, const pm
|
|||
.encoding_changed = false,
|
||||
.pattern_matching_newlines = false,
|
||||
.in_keyword_arg = false,
|
||||
.current_param_name = 0,
|
||||
.semantic_token_seen = false,
|
||||
.frozen_string_literal = false,
|
||||
.suppress_warnings = false
|
||||
|
|
|
@ -1836,7 +1836,7 @@ module Prism
|
|||
proc { |foo = foo| }
|
||||
proc { |foo: foo| }
|
||||
RUBY
|
||||
message = 'Invalid circular reference in a default parameter'
|
||||
message = 'Parameter default value references itself'
|
||||
assert_errors expression(source), source, [
|
||||
[message, 14..17],
|
||||
[message, 37..40],
|
||||
|
|
Загрузка…
Ссылка в новой задаче