diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-01-27 10:41:43 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-01-27 10:41:43 +0000 |
commit | 7ea65f9be26d17d4bcb50b85301bf5bf379e72ef (patch) | |
tree | e876e5d395d16f4922ce6a8297ab0f422e4d0917 /compile.c | |
parent | d0fa578cdcb041ec3e42d8bcba0bfcf9984def6d (diff) |
compile.c: try to convert in massign `for`
* compile.c (compile_for_masgn): try to convert to an Array if an
element of massign `for` is not an Array.
[ruby-core:84931] [Bug #14374]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62073 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compile.c')
-rw-r--r-- | compile.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -5040,7 +5040,7 @@ static int compile_for_masgn(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped) { /* massign to var in "for" - * args.length == 1 && Array === (tmp = args[0]) ? tmp : args + * (args.length == 1 && Array.try_convert(args[0])) || args */ const int line = nd_line(node); const NODE *var = node->nd_var; @@ -5056,8 +5056,9 @@ compile_for_masgn(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const nod ADD_INSN1(ret, line, putobject, INT2FIX(0)); ADD_CALL(ret, line, idAREF, INT2FIX(1)); ADD_INSN1(ret, line, putobject, rb_cArray); - ADD_INSN1(ret, line, topn, INT2FIX(1)); - ADD_CALL(ret, line, idEqq, INT2FIX(1)); + ADD_INSN(ret, line, swap); + ADD_CALL(ret, line, rb_intern("try_convert"), INT2FIX(1)); + ADD_INSN(ret, line, dup); ADD_INSNL(ret, line, branchunless, not_ary); ADD_INSN(ret, line, swap); ADD_LABEL(ret, not_ary); |