"expr_value" can be error
So that "IF" node is kept in the case below ``` def m if end ``` [Feature #19013]
This commit is contained in:
parent
4bfdf6d06d
commit
3531086095
Notes:
git
2022-10-08 17:59:34 +09:00
6
parse.y
6
parse.y
@ -1901,6 +1901,12 @@ expr_value : expr
|
|||||||
value_expr($1);
|
value_expr($1);
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
}
|
}
|
||||||
|
| error
|
||||||
|
{
|
||||||
|
/*%%%*/
|
||||||
|
$$ = NEW_ERROR(&@$);
|
||||||
|
/*% %*/
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
expr_value_do : {COND_PUSH(1);} expr_value do {COND_POP();}
|
expr_value_do : {COND_PUSH(1);} expr_value do {COND_POP();}
|
||||||
|
@ -1007,4 +1007,39 @@ dummy
|
|||||||
body: nil))))))
|
body: nil))))))
|
||||||
EXP
|
EXP
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_error_tolerant_expr_value_can_be_error
|
||||||
|
node = RubyVM::AbstractSyntaxTree.parse(<<~STR, error_tolerant: true)
|
||||||
|
def m
|
||||||
|
if
|
||||||
|
end
|
||||||
|
STR
|
||||||
|
|
||||||
|
str = ""
|
||||||
|
PP.pp(node, str)
|
||||||
|
assert_equal(<<~EXP, str)
|
||||||
|
(SCOPE@1:0-3:3
|
||||||
|
tbl: []
|
||||||
|
args: nil
|
||||||
|
body:
|
||||||
|
(DEFN@1:0-3:3
|
||||||
|
mid: :m
|
||||||
|
body:
|
||||||
|
(SCOPE@1:0-3:3
|
||||||
|
tbl: []
|
||||||
|
args:
|
||||||
|
(ARGS@1:5-1:5
|
||||||
|
pre_num: 0
|
||||||
|
pre_init: nil
|
||||||
|
opt: nil
|
||||||
|
first_post: nil
|
||||||
|
post_num: 0
|
||||||
|
post_init: nil
|
||||||
|
rest: nil
|
||||||
|
kw: nil
|
||||||
|
kwrest: nil
|
||||||
|
block: nil)
|
||||||
|
body: (IF@2:2-3:3 (ERROR@3:0-3:3) nil nil))))
|
||||||
|
EXP
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user