Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixes #4662. Line numbers in backtrace with multiline method invocati…
…on are sometimes different from CRuby.
  • Loading branch information
enebo committed Jun 12, 2017
1 parent f86604a commit d7d063d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion core/src/main/java/org/jruby/ir/IRBuilder.java
Expand Up @@ -386,14 +386,18 @@ private void emitEnsureBlocks(IRLoop loop) {
}
}

private Operand buildOperand(Variable result, Node node) throws NotCompilableException {
private void determineIfWeNeedLineNumber(Node node) {
if (node.isNewline()) {
int currLineNum = node.getLine();
if (currLineNum != _lastProcessedLineNum) { // Do not emit multiple line number instrs for the same line
needsLineNumInfo = true;
_lastProcessedLineNum = currLineNum;
}
}
}

private Operand buildOperand(Variable result, Node node) throws NotCompilableException {
determineIfWeNeedLineNumber(node);

switch (node.getNodeType()) {
case ALIASNODE: return buildAlias((AliasNode) node);
Expand Down Expand Up @@ -2700,6 +2704,7 @@ public Operand buildFCall(Variable result, FCallNode fcallNode) {
}
}

determineIfWeNeedLineNumber(fcallNode); // buildOperand for fcall was papered over by args operand building so we check once more.
CallInstr callInstr = CallInstr.create(scope, CallType.FUNCTIONAL, result, fcallNode.getName(), buildSelf(), args, block);
receiveBreakException(block, callInstr);
return result;
Expand Down

0 comments on commit d7d063d

Please sign in to comment.