parent
41c00bc97e
commit
ae76c8a11e
5
NEWS.md
5
NEWS.md
@ -257,6 +257,10 @@ changelog for details of the default gems or bundled gems.
|
||||
removed. Environment variables `RUBY_GC_HEAP_%d_INIT_SLOTS` should be
|
||||
used instead. [[Feature #19785]]
|
||||
|
||||
* `it` calls without arguments in a block with no ordinary parameters are
|
||||
deprecated. `it` will be a reference to the first block parameter in Ruby 3.4.
|
||||
[[Feature #18980]]
|
||||
|
||||
## Stdlib compatibility issues
|
||||
|
||||
* `racc` is promoted to bundled gems.
|
||||
@ -374,6 +378,7 @@ changelog for details of the default gems or bundled gems.
|
||||
[Feature #18515]: https://bugs.ruby-lang.org/issues/18515
|
||||
[Feature #18551]: https://bugs.ruby-lang.org/issues/18551
|
||||
[Feature #18885]: https://bugs.ruby-lang.org/issues/18885
|
||||
[Feature #18980]: https://bugs.ruby-lang.org/issues/18980
|
||||
[Feature #18949]: https://bugs.ruby-lang.org/issues/18949
|
||||
[Bug #19012]: https://bugs.ruby-lang.org/issues/19012
|
||||
[Bug #19150]: https://bugs.ruby-lang.org/issues/19150
|
||||
|
5
parse.y
5
parse.y
@ -12785,6 +12785,11 @@ gettable(struct parser_params *p, ID id, const YYLTYPE *loc)
|
||||
}
|
||||
# endif
|
||||
/* method call without arguments */
|
||||
if (dyna_in_block(p) && id == rb_intern("it")
|
||||
&& !(DVARS_TERMINAL_P(p->lvtbl->args) || DVARS_TERMINAL_P(p->lvtbl->args->prev))
|
||||
&& p->max_numparam != ORDINAL_PARAM) {
|
||||
rb_warn0("`it` calls without arguments will refer to the first block param in Ruby 3.4; use it() or self.it");
|
||||
}
|
||||
return NEW_VCALL(id, loc);
|
||||
case ID_GLOBAL:
|
||||
return NEW_GVAR(id, loc);
|
||||
|
@ -1719,6 +1719,17 @@ eom
|
||||
assert_valid_syntax("p { [_1 **2] }")
|
||||
end
|
||||
|
||||
def test_it
|
||||
assert_no_warning(/`it`/) {eval('if false; it; end')}
|
||||
assert_no_warning(/`it`/) {eval('def foo; it; end')}
|
||||
assert_warn(/`it`/) {eval('0.times { it }')}
|
||||
assert_no_warning(/`it`/) {eval('0.times { || it }')}
|
||||
assert_no_warning(/`it`/) {eval('0.times { |_n| it }')}
|
||||
assert_warn(/`it`/) {eval('0.times { it; it = 1; it }')}
|
||||
assert_no_warning(/`it`/) {eval('0.times { it = 1; it }')}
|
||||
assert_no_warning(/`it`/) {eval('it = 1; 0.times { it }')}
|
||||
end
|
||||
|
||||
def test_value_expr_in_condition
|
||||
mesg = /void value expression/
|
||||
assert_syntax_error("tap {a = (true ? next : break)}", mesg)
|
||||
|
Loading…
x
Reference in New Issue
Block a user