Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add macro method ASTNode#nil? (#10850)
#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 to is_a?(Nil). In the macro interpreter, no value can be of type Nil because that's a runtime type, so any nil? call would always return false. 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 return true. So this patch implements ASTNode#nil? in the macro interpreter. It returns true if the value is a NilLiteral or Nop. 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.
- Loading branch information