Commit f0649ab
Make
Follow up [Bug #21029].
Currently, `defined? (x;)` returns `expression` when using Prism parser.
See:
- ruby#12949
- https://bugs.ruby-lang.org/issues/21029
However, `defined? (x;)` returns nil when using parse.y, as reported in bug ticket comment and test-all (when using parse.y parser) test result.
This change adds a context flag to track trailing semicolons in defined? scope.
When a trailing semicolon is detected within a defined? scope, the generated AST node is wrapped with NODE_BLOCK.
This change ensures consistent behavior with `defined? (;x)` .defined? (x;) return expression when using parse.y parser1 parent 54ec482 commit f0649ab
1 file changed
+20
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
314 | 314 | | |
315 | 315 | | |
316 | 316 | | |
| 317 | + | |
317 | 318 | | |
318 | 319 | | |
319 | 320 | | |
| |||
4041 | 4042 | | |
4042 | 4043 | | |
4043 | 4044 | | |
| 4045 | + | |
4044 | 4046 | | |
4045 | 4047 | | |
4046 | 4048 | | |
| |||
4428 | 4430 | | |
4429 | 4431 | | |
4430 | 4432 | | |
| 4433 | + | |
4431 | 4434 | | |
4432 | 4435 | | |
4433 | 4436 | | |
| |||
6706 | 6709 | | |
6707 | 6710 | | |
6708 | 6711 | | |
6709 | | - | |
| 6712 | + | |
| 6713 | + | |
| 6714 | + | |
| 6715 | + | |
| 6716 | + | |
| 6717 | + | |
| 6718 | + | |
| 6719 | + | |
6710 | 6720 | | |
6711 | 6721 | | |
6712 | 6722 | | |
| |||
13013 | 13023 | | |
13014 | 13024 | | |
13015 | 13025 | | |
| 13026 | + | |
| 13027 | + | |
| 13028 | + | |
13016 | 13029 | | |
13017 | 13030 | | |
13018 | 13031 | | |
| |||
13025 | 13038 | | |
13026 | 13039 | | |
13027 | 13040 | | |
| 13041 | + | |
| 13042 | + | |
| 13043 | + | |
| 13044 | + | |
| 13045 | + | |
| 13046 | + | |
13028 | 13047 | | |
13029 | 13048 | | |
13030 | 13049 | | |
| |||
0 commit comments