Bug #21029
open
Prism behavior for `defined? (;x)` differs
Description
Prism has a different behavior for (;expr)
when used in defined?
predicate:
% ./miniruby --parser=prism -e "p defined? (;x)"
nil
% ./miniruby --parser=parse.y -e "p defined? (;x)"
"expression"
Although not a significant difference, aligning either of them with the other would be better.
Updated by kddnewton (Kevin Newton) about 1 month ago
- Assignee set to prism
Updated by kddnewton (Kevin Newton) about 1 month ago
I think we should change parse.y
to match this behavior. I will ask around.
Updated by hsbt (Hiroshi SHIBATA) 10 days ago
- Status changed from Open to Assigned
Updated by matz (Yukihiro Matsumoto) 9 days ago
I think compound expressions (expressions (including empty) concatenated by semicolons) should be “expression” as parse.y
.
It makes defined?
simpler. I know the current defined?
behavior recursively check for defined-ness (e.g., method parameters), I don't think we need that complexity here.
Matz.
Updated by qnighy (Masaki Hara) 9 days ago
I think compound expressions (expressions (including empty) concatenated by semicolons) should be “expression” as
parse.y
.
Interestingly enough though:
% ruby --parser=prism -e "p defined? (x;)"
nil
% ruby --parser=parse.y -e "p defined? (x;)"
nil
% ruby --parser=prism -e "p defined? (;x)"
nil
% ruby --parser=parse.y -e "p defined? (;x)"
"expression"
Updated by kddnewton (Kevin Newton) 9 days ago
@matz (Yukihiro Matsumoto) for what it's worth, it makes it much more complicated in the Prism compiler because we don't have empty statements. So it's not a recursive situation at the moment, it's just a single statement.
As @qnighy points out, should this be "expression" for when there is a trailing ;
?