Skip to content

Commit

Permalink
Allow dot3 in defs singleton
Browse files Browse the repository at this point in the history
  • Loading branch information
tompng committed Sep 28, 2024
1 parent 7e19904 commit 1f75648
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 7 additions & 2 deletions parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -3426,7 +3426,6 @@ defn_head : k_def def_name
defs_head : k_def singleton dot_or_colon
{
SET_LEX_STATE(EXPR_FNAME);
p->ctxt.in_argdef = 1;
}
def_name
{
Expand Down Expand Up @@ -6746,8 +6745,14 @@ singleton : var_ref
value_expr($1);
$$ = $1;
}
| '(' {SET_LEX_STATE(EXPR_BEG);} expr rparen
| '('
{
SET_LEX_STATE(EXPR_BEG);
p->ctxt.in_argdef = 0;
}
expr rparen
{
p->ctxt.in_argdef = 1;
NODE *expr = last_expr_node($3);
switch (nd_type(expr)) {
case NODE_STR:
Expand Down
2 changes: 2 additions & 0 deletions test/ruby/test_syntax.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1968,6 +1968,8 @@ def test_argument_forwarding
assert_valid_syntax("def foo b = 1, ...; bar(...); end")
assert_valid_syntax("(def foo ...\n bar(...)\nend)")
assert_valid_syntax("(def foo ...; bar(...); end)")
assert_valid_syntax("def (1...).foo ...; bar(...); end")
assert_valid_syntax("def (tap{1...}).foo ...; bar(...); end")
assert_valid_syntax('def ==(...) end')
assert_valid_syntax('def [](...) end')
assert_valid_syntax('def nil(...) end')
Expand Down

0 comments on commit 1f75648

Please sign in to comment.