@@ -545,6 +545,11 @@ def newrange(flag)
545
545
iseq . push ( [ :newrange , flag ] )
546
546
end
547
547
548
+ def nop
549
+ stack . change_by ( 0 )
550
+ iseq . push ( [ :nop ] )
551
+ end
552
+
548
553
def objtostring ( method_id , argc , flag )
549
554
stack . change_by ( -1 + 1 )
550
555
iseq . push ( [ :objtostring , call_data ( method_id , argc , flag ) ] )
@@ -1190,13 +1195,9 @@ def visit_float(node)
1190
1195
def visit_for ( node )
1191
1196
visit ( node . collection )
1192
1197
1193
- # Be sure we set up the local table before we start compiling the body
1194
- # of the for loop.
1195
- if node . index . is_a? ( VarField ) && node . index . value . is_a? ( Ident )
1196
- name = node . index . value . value . to_sym
1197
- unless current_iseq . local_variables . include? ( name )
1198
- current_iseq . local_variables << name
1199
- end
1198
+ name = node . index . value . value . to_sym
1199
+ unless current_iseq . local_variables . include? ( name )
1200
+ current_iseq . local_variables << name
1200
1201
end
1201
1202
1202
1203
block_iseq =
@@ -1206,6 +1207,19 @@ def visit_for(node)
1206
1207
current_iseq ,
1207
1208
node . statements
1208
1209
) do
1210
+ current_iseq . argument_options [ :lead_num ] ||= 0
1211
+ current_iseq . argument_options [ :lead_num ] += 1
1212
+ current_iseq . argument_options [ :ambiguous_param0 ] = true
1213
+
1214
+ current_iseq . argument_size += 1
1215
+ current_iseq . local_variables << 2
1216
+
1217
+ builder . getlocal ( 0 , 0 )
1218
+
1219
+ local_variable = current_iseq . local_variable ( name )
1220
+ builder . setlocal ( local_variable . index , local_variable . level )
1221
+ builder . nop
1222
+
1209
1223
visit ( node . statements )
1210
1224
builder . leave
1211
1225
end
0 commit comments