Revert "[Bug #20965] Define it like an ordinary argument" (#12418)

Revert "[Bug #20965] Define `it` like an ordinary argument (#12398)"

Reverts ruby/ruby#12398 as per https://bugs.ruby-lang.org/issues/20970#note-6 and https://bugs.ruby-lang.org/issues/20965#note-7.
We need more time to design the intended behavior, and it's too late for Ruby 3.4.
This commit is contained in:
Takashi Kokubun 2024-12-22 20:46:50 -08:00 committed by GitHub
parent b19fcd02fa
commit 667a0f9f92
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
Notes: git 2024-12-23 04:47:08 +00:00
Merged-By: k0kubun <takashikkbn@gmail.com>
4 changed files with 4 additions and 8 deletions

View File

@ -63,7 +63,6 @@ firstline, predefined = __LINE__+1, %[\
pack pack
buffer buffer
include? include?
it
_ UScore _ UScore

View File

@ -13060,7 +13060,7 @@ gettable(struct parser_params *p, ID id, const YYLTYPE *loc)
return 0; return 0;
} }
if (!p->it_id) { if (!p->it_id) {
p->it_id = idIt; p->it_id = internal_id(p);
vtable_add(p->lvtbl->args, p->it_id); vtable_add(p->lvtbl->args, p->it_id);
} }
NODE *node = NEW_DVAR(p->it_id, loc); NODE *node = NEW_DVAR(p->it_id, loc);

View File

@ -5960,7 +5960,7 @@ pm_compile_scope_node(rb_iseq_t *iseq, pm_scope_node_t *scope_node, const pm_nod
} }
if (scope_node->parameters != NULL && PM_NODE_TYPE_P(scope_node->parameters, PM_IT_PARAMETERS_NODE)) { if (scope_node->parameters != NULL && PM_NODE_TYPE_P(scope_node->parameters, PM_IT_PARAMETERS_NODE)) {
ID local = idIt; ID local = rb_make_temporary_id(local_index);
local_table_for_iseq->ids[local_index++] = local; local_table_for_iseq->ids[local_index++] = local;
} }

View File

@ -1930,15 +1930,12 @@ eom
1.times do 1.times do
[ [
assert_equal(0, it), assert_equal(0, it),
assert_equal([0], eval('[:a].map{it}')), assert_equal([:a], eval('[:a].map{it}')),
assert_equal(0, eval('it')), assert_raise(NameError) {eval('it')},
] ]
end end
assert_valid_syntax('proc {def foo(_);end;it}') assert_valid_syntax('proc {def foo(_);end;it}')
assert_syntax_error('p { [it **2] }', /unexpected \*\*/) assert_syntax_error('p { [it **2] }', /unexpected \*\*/)
b = proc {it; binding}.call
assert_include(b.local_variables, :it)
end end
def test_value_expr_in_condition def test_value_expr_in_condition