Closed
Bug 214594
Opened 22 years ago
Closed 22 years ago
Wrong line number for exceptions in while(condition) in compiled mode
Categories
(Rhino Graveyard :: Compiler, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
1.5R5
People
(Reporter: hannesw, Assigned: norrisboyd)
Details
Attachments
(1 file)
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5a) Gecko/20030718
Build Identifier:
When an error occurs while evaluating the condition of a JavaScript while or
do...while statement, the wrong line number is printed by the resulting error
message. The line number printed is that of the last statement in the while
statement's body. This only happens when using optlevel 0 or above, optlevel -1
prints the correct line number. I also checked for and if statements, but the
problem is limited to while and do...while.
Reproducible: Always
Steps to Reproduce:
Save the following as test.js:
while (x.y.z) {
a = 1;
b = 2;
c = 3;
}
java -jar js.jar -f test.js
Actual Results:
ReferenceError: "x" is not defined. (.../test.js; line 4)
Expected Results:
ReferenceError: "x" is not defined. (.../test.js; line 1)
Comment 1•22 years ago
|
||
cc'ing Igor -
Comment 2•22 years ago
|
||
The reason for the bug is that the parser did not propagate proper line number
for loop condition when it converts internally the while loop to do-while with
an initial jump to the loop end. As a result JVM byte code for the condition
would inherit its line number from the last loop statement.
The bug does not affect the pure interpreter since the interpreter uses dynamic
information from the last line number mark and there the condition would get
proper number from the loop as additional goto to the loop end would not affect
the last line number mark.
To address this the patch adds a line mark to the parse tree before the
condition.
Comment 3•22 years ago
|
||
I committed the fix.
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•