summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2023-12-06 23:14:59 -0800
committerGitHub <noreply@github.com>2023-12-07 07:14:59 +0000
commitae76c8a11e707176a53c84016256646308f36207 (patch)
tree12595d3e93268a839ce82b5f1ce2c3eec1fb0aca /parse.y
parent41c00bc97ebf237fd04ce740d0dfd0681f4a28c7 (diff)
Warn `it` (#9152)
https://bugs.ruby-lang.org/issues/18980
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y5
1 files changed, 5 insertions, 0 deletions
diff --git a/parse.y b/parse.y
index 34c9152bea..b35547ad74 100644
--- a/parse.y
+++ b/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);