diff --git a/core/src/main/java/org/jruby/ir/instructions/IntegerMathInstr.java b/core/src/main/java/org/jruby/ir/instructions/IntegerMathInstr.java index a2be073aa25..beb6f14c5cd 100644 --- a/core/src/main/java/org/jruby/ir/instructions/IntegerMathInstr.java +++ b/core/src/main/java/org/jruby/ir/instructions/IntegerMathInstr.java @@ -47,6 +47,8 @@ public static IntegerMathInstr decode(IRReaderDecoder d) { @Override public void encode(IRWriterEncoder e) { super.encode(e); + e.encode(getOperand1()); + e.encode(getOperand2()); e.encode(op.ordinal()); } diff --git a/core/src/main/java/org/jruby/ir/operands/TemporaryLocalVariable.java b/core/src/main/java/org/jruby/ir/operands/TemporaryLocalVariable.java index 7ef48a2a236..947b8bf182f 100644 --- a/core/src/main/java/org/jruby/ir/operands/TemporaryLocalVariable.java +++ b/core/src/main/java/org/jruby/ir/operands/TemporaryLocalVariable.java @@ -90,6 +90,7 @@ public static TemporaryLocalVariable decode(IRReaderDecoder d) { case CURRENT_MODULE: return TemporaryCurrentModuleVariable.decode(d); case FLOAT: return TemporaryFloatVariable.decode(d); case FIXNUM: return TemporaryFixnumVariable.decode(d); + case INT: return TemporaryIntVariable.decode(d); case BOOLEAN: return TemporaryBooleanVariable.decode(d); case LOCAL: return d.getCurrentScope().getManager().newTemporaryLocalVariable(d.decodeInt()); } diff --git a/core/src/main/java/org/jruby/ir/persistence/IRReaderStream.java b/core/src/main/java/org/jruby/ir/persistence/IRReaderStream.java index f72ae27650e..18ea05a6f57 100644 --- a/core/src/main/java/org/jruby/ir/persistence/IRReaderStream.java +++ b/core/src/main/java/org/jruby/ir/persistence/IRReaderStream.java @@ -252,8 +252,10 @@ public Instr decodeInstr() { case ALIAS: return AliasInstr.decode(this); case ARRAY_DEREF: return ArrayDerefInstr.decode(this); case ATTR_ASSIGN: return AttrAssignInstr.decode(this); + case AS_FIXNUM: return AsFixnumInstr.decode(this); case AS_STRING: return AsStringInstr.decode(this); case B_FALSE: return BFalseInstr.decode(this); + case B_INT: return BIntInstr.decode(this); case B_NIL: return BNilInstr.decode(this); case B_SWITCH: return BSwitchInstr.decode(this); case B_TRUE: return BTrueInstr.decode(this); @@ -301,6 +303,7 @@ public Instr decodeInstr() { case GVAR_ALIAS: return GVarAliasInstr.decode(this); case INHERITANCE_SEARCH_CONST: return InheritanceSearchConstInstr.decode(this); case INSTANCE_SUPER: return InstanceSuperInstr.decode(this); + case INT_MATH: return IntegerMathInstr.decode(this); case JUMP: return JumpInstr.decode(this); case LABEL: return LabelInstr.decode(this); case LAMBDA: return BuildLambdaInstr.decode(this); diff --git a/spec/compiler/general_spec.rb b/spec/compiler/general_spec.rb index 2bd24183689..eb1aac4b8e3 100644 --- a/spec/compiler/general_spec.rb +++ b/spec/compiler/general_spec.rb @@ -1034,6 +1034,13 @@ class AFromLocal < a run("def foo; case 0; when 1; return 2 if self.nil?; end; return 3; end; foo") {|result| expect(result).to eq 3 } end + # See https://github.com/jruby/jruby/issues/9834 + it "compiles array patterns" do + run('[([1] in [1]), ([1, 2] in [_, 2]), ([1, 2, 3] in [1, *r]) && r, (case [3]; in [x] then x; end)]') do |x| + expect(x).to eq [true, true, [2, 3], 3] + end + end + it "assigns named groups in regular expressions to local variables" do # named groups with capture run("