-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[Bug #21669] Thoroughly implement void value expression check #15498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
The following files are maintained in the following upstream repositories:
Please file a pull request to the above instead. Thank you! |
This comment has been minimized.
This comment has been minimized.
f18498d to
21deb1b
Compare
If any `rescue` node is non-void, the enclosing block is also non-void.
If `rescue`-else node node is void, the `rescue`-body is also void.
If the all `when` and `else` branches are void, the `case` is also void.
If the both branches are void, the `if`/`unless` is also void.
A block containing a void statement that is not contained in a branch is also void.
If the all `in` and `else` branches are void, the `case` is also void.
See https://bugs.ruby-lang.org/issues/21669#note-4 > At line 1067, void_node = vn is executed (and vn is guaranteed to be non-NULL on the line above), so it's impossible for void_node to be NULL at line 1075. Thus, it is indeed dead code.
A block containing a void statement that is not contained in a branch is also void.
21deb1b to
74ea62b
Compare
|
I found these two cases where no warning about unused assignment is emitted anymore by prism: autoinit = false
block ||= begin
autoinit = true
foo
end
####
block ||= begin
foo = bar
baz
endSeems specifically about optionally assigning the begin block, with just This was introduced in your latest commit (74ea62b) |
[Bug #21669]