Allow dot3 in defs singleton

This commit is contained in:
tompng 2024-09-28 13:15:29 +09:00 committed by Nobuyoshi Nakada
parent 8f678d6989
commit b9e225fcbf
Notes: git 2024-09-28 13:38:02 +00:00
2 changed files with 9 additions and 2 deletions

View File

@ -3426,7 +3426,6 @@ defn_head : k_def def_name
defs_head : k_def singleton dot_or_colon defs_head : k_def singleton dot_or_colon
{ {
SET_LEX_STATE(EXPR_FNAME); SET_LEX_STATE(EXPR_FNAME);
p->ctxt.in_argdef = 1;
} }
def_name def_name
{ {
@ -6746,8 +6745,14 @@ singleton : var_ref
value_expr($1); value_expr($1);
$$ = $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); NODE *expr = last_expr_node($3);
switch (nd_type(expr)) { switch (nd_type(expr)) {
case NODE_STR: case NODE_STR:

View File

@ -1968,6 +1968,8 @@ eom
assert_valid_syntax("def foo b = 1, ...; bar(...); end") assert_valid_syntax("def foo b = 1, ...; bar(...); end")
assert_valid_syntax("(def foo ...\n bar(...)\nend)") assert_valid_syntax("(def foo ...\n bar(...)\nend)")
assert_valid_syntax("(def foo ...; bar(...); end)") 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 [](...) end') assert_valid_syntax('def [](...) end')
assert_valid_syntax('def nil(...) end') assert_valid_syntax('def nil(...) end')