Add specs for the it variable in blocks
For #1216
This is very much a work in progress, I had this file hanging around in Natalie. It's mostly just a PoC, and misses a lot of cases. The numbered_parameters_spec can probably be used as a reference.
There are some relevant new specs in a TruffleRuby corresponding PR https://github.com/oracle/truffleruby/pull/3734. So later we will need to combine them and this PR changes during synchronising TruffleRuby's spec changes with ruby/spec.
The progress of TruffleRuby support of Ruby 3.3 is tracked in https://github.com/oracle/truffleruby/issues/3681. Usually contributors leave a comment when they are starting working on some item.
I have updated this one with the Ruby 3.4 behaviour and rebased it upon the current state. With extra credits for @zverok, the examples on "The Ruby Changes" were very helpful.
This includes the behaviour of Ruby 3.3 and 3.4, so it checks a box in #1265 as well.
I put everything in language/block_spec.rb, since that one already had checks for the it parameter. Since there is also a language/numbered_parameters_spec.rb, I would think this would warrant its own file.
Fun fact: this is the first time in the specs that matched syntax errors in Prism and Parse.y did not match up (https://bugs.ruby-lang.org/issues/21381)
Since there is also a language/numbered_parameters_spec.rb, I would think this would warrant its own file.
Yes, makes sense.
Fun fact: this is the first time in the specs that matched syntax errors in Prism and Parse.y did not match up (https://bugs.ruby-lang.org/issues/21381)
We reported such issues usually in the ruby/prism GitHub repo. It seems the old parser (I mean parse.y) doesn't catch this issue at all and the error is emitted at YARV byte code generation (so we have printed compile error). So Prism seems behaves better and catches the issue earlier.