Bug #2496
closedIncorrect tracing line number for LocalVariableReference and VariableReference
0%
Description
Hi,
I'm using tracing to identify number of line that given expression is on.
In most cases everything is fine apart form LocalVariableReference (and based on a brief look on the code also VariableReference).
Easy way to reproduce this is to have the main file prepared like below:
declare function local:a() {
let $a := 'a'
return $a
};
local:a()
and have an instance of TraceListener configured that has a method enter() like below:
@Override
public void enter(InstructionInfo instructionInfo, XPathContext xPathContext) {
System.out.print("enter " + instructionInfo.toString());
System.out.println(" line: " + instructionInfo.getLineNumber());
System.out.println(" constructType: " + instructionInfo.getConstructType());
}
With this in place just running the sample main file will show that the line with return (constructType: 2014 = RETURN EXPRESSION) is shown with line number of the closing curly brace instead of the line where the return actually is.
I've been able to fix the issue locally (don't know if this is a proper solution though) on Saxon by adding the typical construct of first capturing the offset (on the beggining of the method) and use it to set location at the end.
Please find the diff and the modified file version attached.
Saxon versions affected: 9.5.1.10, 9.6.0.7 (actually all versions that I could find)
Saxon version with fixed issue (attached file): 9.6.0.7
Files
Please register to edit this issue