diff --git a/core/src/main/java/org/jruby/ir/builder/IRBuilder.java b/core/src/main/java/org/jruby/ir/builder/IRBuilder.java index db463dcc73c..c8cbdcda554 100644 --- a/core/src/main/java/org/jruby/ir/builder/IRBuilder.java +++ b/core/src/main/java/org/jruby/ir/builder/IRBuilder.java @@ -1734,11 +1734,10 @@ protected Variable buildDefnCheckIfThenPaths(Label undefLabel, Operand defVal) { } public Operand buildMatch(Variable result, Operand regexp) { - Variable tempLastLine = temp(); - addResultInstr(new GetGlobalVariableInstr(tempLastLine, symbol("$_"))); + Variable lastLine = addResultInstr(new GetGlobalVariableInstr(temp(), symbol("$_"))); if (result == null) result = temp(); - return addResultInstr(new MatchInstr(scope, result, regexp, tempLastLine)); + return addResultInstr(new MatchInstr(scope, result, regexp, lastLine)); } protected Operand buildModule(ByteList name, U cpath, U bodyNode, StaticScope scope, int line, int endLine) {