diff options
author | Nobuyoshi Nakada <[email protected]> | 2024-12-19 16:12:16 +0900 |
---|---|---|
committer | <[email protected]> | 2024-12-18 23:12:16 -0800 |
commit | 46fec0f62a1803d44edb8b06e39ac0f358e56670 () | |
tree | 32b19e3c764f725a3c96c379ef045c12d18e39a4 | |
parent | 2783868de27113040fbfb5401325852fd12fbcd2 (diff) |
[Bug #20965] Define `it` like an ordinary argument (#12398)
Also fixes [Bug #20955]
Notes: Merged-By: k0kubun <[email protected]>
-rw-r--r-- | defs/id.def | 1 | ||||
-rw-r--r-- | parse.y | 2 | ||||
-rw-r--r-- | prism_compile.c | 2 | ||||
-rw-r--r-- | test/ruby/test_syntax.rb | 7 |
4 files changed, 8 insertions, 4 deletions
@@ -63,6 +63,7 @@ firstline, predefined = __LINE__+1, %[\ pack buffer include? _ UScore @@ -13060,7 +13060,7 @@ gettable(struct parser_params *p, ID id, const YYLTYPE *loc) return 0; } if (!p->it_id) { - p->it_id = internal_id(p); vtable_add(p->lvtbl->args, p->it_id); } NODE *node = NEW_DVAR(p->it_id, loc); @@ -5950,7 +5950,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)) { - ID local = rb_make_temporary_id(local_index); local_table_for_iseq->ids[local_index++] = local; } @@ -1930,12 +1930,15 @@ eom 1.times do [ assert_equal(0, it), - assert_equal([:a], eval('[:a].map{it}')), - assert_raise(NameError) {eval('it')}, ] end assert_valid_syntax('proc {def foo(_);end;it}') assert_syntax_error('p { [it **2] }', /unexpected \*\*/) end def test_value_expr_in_condition |