Closed Bug 417040 Opened 16 years ago Closed 8 months ago

JS_Evaluate*Script should ABORT when called with line number of 0

Categories

(Core :: JavaScript Engine, defect)

x86
All
defect

Tracking

()

RESOLVED INCOMPLETE

People

(Reporter: vlad, Unassigned)

References

Details

(Whiteboard: [firebug-p2])

Calling JS_Evaluate*Script with a line number of 0 causes any error reporter function that's set to never be called, even when errors are present.  Changing the dummy line number to 1 causes errors to be reported correctly.
lineno 0 is magic, always has been. Should JS_ASSERT that it's non-zero. Why are you using 0?

/be
People use zero as defaults for counting when they don't know otherwise, and our docs don't indicate the 0 effect clearly enough, apparently.
This is indeed a bug, but we should not try to support lineno 0 -- we just need docs and assertions (DEBUG-only enforcement of API rules is standard operating procedure in SpiderMonkey).

/be
Yep, docs and assertions would be fine.. I was just tossing in a dummy filename/lineno and was scratching my head as to why errors weren't being reported.
brendan writes:
it was 15 years ago but i seem to recall believing line numbers should start at 1, wanting to use unsigned, and needing an out-of-band value as an error or not-valid code
... see js_PCToLineNumber's first return (if (!pc) return 0; -- not a valid line number) jsscript.cpp

bug 332176 is going to fix callers to not pass 0. And then we can use this bug to prevent callers from ever passing 0.
Depends on: 332176
Summary: JS_Evaluate*Script with line number of 0 causes errors to not be reported → JS_Evaluate*Script should ABORT when called with line number of 0
Whiteboard: [firebug-p2]
bug 332176 seems unrelated to me, since Firebug can handle the test case posted there.
Assignee: general → nobody
Severity: normal → S3
Status: NEW → RESOLVED
Closed: 8 months ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.