Add not operator (!) support to type inference#47
Merged
Conversation
ruby-prism represents `!expr` as a CallNode with method name "!", which previously fell through to the general method dispatch path and produced incorrect type results. This change short-circuits the "!" call in process_method_call_common to return TrueClass | FalseClass directly, matching Ruby's actual semantics where `!` always returns a boolean. Also refactor process_and_node / process_or_node to share a common process_binary_logical_op helper, eliminating duplicated union-merge logic. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
!operator type inference: ruby-prism represents!expras aCallNodewith method name"!", which previously fell through to the general method dispatch path and produced incorrect type results. Short-circuit the"!"call inprocess_method_call_commonto returnTrueClass | FalseClassdirectly, matching Ruby's actual semantics.&&/||duplicate logic: Extract common union-merge logic fromprocess_and_nodeandprocess_or_nodeinto a sharedprocess_binary_logical_ophelper.!true,!!true,!nil, receiver type error detection, and method chaining on!results.Test plan
cd rust && cargo test --lib— Rust unit tests passbundle exec rake— Full build + Ruby integration tests pass🤖 Generated with Claude Code