Skip to content

Commit

Permalink
Temporary patch for patch: use different temp for each opt arg.
Browse files Browse the repository at this point in the history
Reusing the same one seemed to cause early opt values to leak into
later opt arg processing. I did not investigate in depth, but it
caused test_eej in test/jruby/test_vietnamese_charset.rb to fail
due to the YAML emitter getting assigned a Hash instance in
YAMLTree.new (psych/visitors/yaml_tree.rb:48), the default value
for "options" an earlier opt arg.
headius committed Mar 7, 2016
1 parent 102a088 commit 02b2c96
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ir/IRBuilder.java
Original file line number Diff line number Diff line change
@@ -1914,14 +1914,14 @@ protected void receiveNonBlockArgs(final ArgsNode argsNode) {
// Now for opt args
if (opt > 0) {
int optIndex = argsNode.getOptArgIndex();
Variable temp = createTemporaryVariable();
for (int j = 0; j < opt; j++, argIndex++) {
// Jump to 'l' if this arg is not null. If null, fall through and build the default value!
Label l = getNewLabel();
OptArgNode n = (OptArgNode)args[optIndex + j];
String argName = n.getName();
Variable av = getNewLocalVariable(argName, 0);
if (scope instanceof IRMethod) addArgumentDescription(ArgumentType.opt, argName);
Variable temp = createTemporaryVariable();
// You need at least required+j+1 incoming args for this opt arg to get an arg at all
addInstr(new ReceiveOptArgInstr(temp, signature.required(), signature.pre(), j));
addInstr(BNEInstr.create(l, temp, UndefinedValue.UNDEFINED)); // if 'av' is not undefined, go to default

0 comments on commit 02b2c96

Please sign in to comment.