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.
#10616 removed a bug that the compiler accepted calls to
nil?
in macro expressions where that method does not exist. These calls were internally transformed tois_a?(Nil)
. In the macro interpreter, no value can be of typeNil
because that's a runtime type, so anynil?
call would always returnfalse
.Removing that transformation from the parser made
nil?
calls in macro expressions errors because that method is not defined.But users would expect
nil.nil?
to returntrue
. So this patch implementsASTNode#nil?
in the macro interpreter. It returnstrue
if the value is aNilLiteral
orNop
.This is technically a feature addition, but we should still merge it for 1.1 despite the feature freeze. It actually avoids a breaking change that would occur with #10616 alone. Code that worked in 1.0 would no longer compile (even though it was already broken before and just worked by chance). With this PR, it continues to compile and fulfills the intended purpose.