mirror of
https://github.com/ruby/ruby.git
synced 2026-08-03 13:08:59 +08:00
[ruby/prism] Revert "Reject p(p a, &block => value) and similar"
https://github.com/ruby/prism/commit/fef2c20777
This commit is contained in:
parent
8d73a18187
commit
b75cf83a33
@ -14244,25 +14244,6 @@ parse_assocs(pm_parser_t *parser, pm_static_literals_t *literals, pm_node_t *nod
|
||||
return contains_keyword_splat;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
argument_allowed_for_bare_hash(pm_parser_t *parser, pm_node_t *argument) {
|
||||
if (pm_symbol_node_label_p(argument)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (PM_NODE_TYPE(argument)) {
|
||||
case PM_CALL_NODE: {
|
||||
pm_call_node_t *cast = (pm_call_node_t *) argument;
|
||||
if (cast->opening_loc.start == NULL && cast->arguments != NULL) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
return accept1(parser, PM_TOKEN_EQUAL_GREATER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Append an argument to a list of arguments.
|
||||
*/
|
||||
@ -14420,7 +14401,7 @@ parse_arguments(pm_parser_t *parser, pm_arguments_t *arguments, bool accepts_for
|
||||
bool contains_keywords = false;
|
||||
bool contains_keyword_splat = false;
|
||||
|
||||
if (argument_allowed_for_bare_hash(parser, argument)){
|
||||
if (pm_symbol_node_label_p(argument) || accept1(parser, PM_TOKEN_EQUAL_GREATER)) {
|
||||
if (parsed_bare_hash) {
|
||||
pm_parser_err_previous(parser, PM_ERR_ARGUMENT_BARE_HASH);
|
||||
}
|
||||
|
||||
@ -1,41 +0,0 @@
|
||||
p(p a, x: b => value)
|
||||
^~ unexpected '=>'; expected a `)` to close the arguments
|
||||
^ unexpected ')', expecting end-of-input
|
||||
^ unexpected ')', ignoring it
|
||||
|
||||
p(p a, x: => value)
|
||||
^~ unexpected '=>'; expected a `)` to close the arguments
|
||||
^ unexpected ')', expecting end-of-input
|
||||
^ unexpected ')', ignoring it
|
||||
|
||||
p(p a, &block => value)
|
||||
^~ unexpected '=>'; expected a `)` to close the arguments
|
||||
^ unexpected ')', expecting end-of-input
|
||||
^ unexpected ')', ignoring it
|
||||
|
||||
p(p a, *args => value)
|
||||
^~ unexpected '=>'; expected a `)` to close the arguments
|
||||
^ unexpected ')', expecting end-of-input
|
||||
^ unexpected ')', ignoring it
|
||||
|
||||
p(p a, **kwargs => value)
|
||||
^~ unexpected '=>'; expected a `)` to close the arguments
|
||||
^ unexpected ')', expecting end-of-input
|
||||
^ unexpected ')', ignoring it
|
||||
|
||||
p p 1, &block => 2, &block
|
||||
^~ unexpected '=>', expecting end-of-input
|
||||
^~ unexpected '=>', ignoring it
|
||||
^ unexpected ',', expecting end-of-input
|
||||
^ unexpected ',', ignoring it
|
||||
^ unexpected '&', ignoring it
|
||||
|
||||
p p p 1 => 2 => 3 => 4
|
||||
^~ unexpected '=>', expecting end-of-input
|
||||
^~ unexpected '=>', ignoring it
|
||||
|
||||
p[p a, x: b => value]
|
||||
^ expected a matching `]`
|
||||
^ unexpected ']', expecting end-of-input
|
||||
^ unexpected ']', ignoring it
|
||||
|
||||
@ -39,9 +39,3 @@ def foo = bar 1
|
||||
!foo 1 or !bar 2
|
||||
|
||||
not !foo 1
|
||||
|
||||
foo(bar baz, key => value)
|
||||
|
||||
foo(bar baz, KEY => value)
|
||||
|
||||
foo(bar baz, :key => value)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user