Reject 'class << (return); end` by "void value expression"

This commit is contained in:
TSUYUSATO Kitsune 2023-11-14 17:15:37 +09:00 committed by Nobuyoshi Nakada
parent 04eb40b633
commit fe746747b4

10
parse.y
View File

@ -4124,7 +4124,7 @@ primary : literal
p->ctxt.in_class = $k_class.in_class; p->ctxt.in_class = $k_class.in_class;
p->ctxt.shareable_constant_value = $k_class.shareable_constant_value; p->ctxt.shareable_constant_value = $k_class.shareable_constant_value;
} }
| k_class tLSHFT expr | k_class tLSHFT expr_value
{ {
begin_definition("", &@k_class, &@tLSHFT); begin_definition("", &@k_class, &@tLSHFT);
} }
@ -4133,12 +4133,12 @@ primary : literal
k_end k_end
{ {
/*%%%*/ /*%%%*/
$$ = NEW_SCLASS($expr, $bodystmt, &@$); $$ = NEW_SCLASS($expr_value, $bodystmt, &@$);
nd_set_line(RNODE_SCLASS($$)->nd_body, @k_end.end_pos.lineno); nd_set_line(RNODE_SCLASS($$)->nd_body, @k_end.end_pos.lineno);
set_line_body($bodystmt, nd_line($expr)); set_line_body($bodystmt, nd_line($expr_value));
fixpos($$, $expr); fixpos($$, $expr_value);
/*% %*/ /*% %*/
/*% ripper: sclass!($expr, $bodystmt) %*/ /*% ripper: sclass!($expr_value, $bodystmt) %*/
local_pop(p); local_pop(p);
p->ctxt.in_def = $k_class.in_def; p->ctxt.in_def = $k_class.in_def;
p->ctxt.in_class = $k_class.in_class; p->ctxt.in_class = $k_class.in_class;