Skip to content

Conversation

@nobu
Copy link
Member

@nobu nobu commented Dec 11, 2025

@github-actions
Copy link

The following files are maintained in the following upstream repositories:

  • https://github.com/ruby/prism
    • prism/prism.c
    • test/prism/errors/3.3-3.4/singleton_method_for_literals.txt
    • test/prism/errors/3.4-3.4/void_value.txt
    • test/prism/errors/4.0/singleton_method_for_literals.txt
    • test/prism/errors/4.0/void_value.txt
    • test/prism/errors/void_value_expression_in_begin_statement.txt
    • test/prism/fixtures/3.3-3.4/void_value.txt
    • test/prism/fixtures/4.0/void_value.txt
    • test/prism/fixtures/non_void_value.txt
    • test/prism/ruby/ripper_test.rb
    • test/prism/ruby/ruby_parser_test.rb

Please file a pull request to the above instead. Thank you!

@launchable-app

This comment has been minimized.

@nobu nobu force-pushed the void-value-expression-check branch 2 times, most recently from f18498d to 21deb1b Compare December 11, 2025 15:47
nobu and others added 10 commits December 12, 2025 09:26
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.
@nobu nobu force-pushed the void-value-expression-check branch from 21deb1b to 74ea62b Compare December 12, 2025 00:27
@Earlopain
Copy link
Contributor

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
end

Seems specifically about optionally assigning the begin block, with just = or no assignment at all the warning is as it was previously.

This was introduced in your latest commit (74ea62b)

@nobu nobu added the ruby 4.1 label Dec 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants