Closed Bug 384279 Opened 17 years ago Closed 9 years ago

Strict warning "does not always return a value" even occurs when the function is missing its closing brace

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
minor

Tracking

()

RESOLVED WONTFIX

People

(Reporter: jruderman, Unassigned)

References

Details

(Keywords: testcase)

js> options("strict"); eval("function f(a) { if(a) return 1;") typein:1: strict warning: function f does not always return a value: typein:1: strict warning: function f(a) { if(a) return 1; typein:1: strict warning: ..............................^ typein:1: SyntaxError: missing } after function body: typein:1: function f(a) { if(a) return 1; typein:1: ..............................^ I don't think the strict warning is necessary here :)
Why is this error not necessary? Consider: f(undefined)
Because the function doesn't even compile. If the function had a closing brace, the warning would be appropriate.
Oh, hah! I added that "}" assuming you had typod. I get this in a current trunk build of the shell: js> options("strict"); eval("function f(a) { if(a) return 1;") typein:1: SyntaxError: missing } after function body: typein:1: function f(a) { if(a) return 1; typein:1: ..............................^
Oh, interesting. This is different depending on how I start the shell! crowdermac:~/mozilla/js/src crowder$ ./Darwin_DBG.OBJ/js -s js> options("strict"); eval("function f(a) { if(a) return 1;") typein:1: SyntaxError: missing } after function body: typein:1: function f(a) { if(a) return 1; typein:1: ..............................^ crowdermac:~/mozilla/js/src crowder$ ./Darwin_DBG.OBJ/js js> options("strict"); eval("function f(a) { if(a) return 1;") typein:1: strict warning: function f does not always return a value: typein:1: strict warning: function f(a) { if(a) return 1; typein:1: strict warning: ..............................^ typein:1: SyntaxError: missing } after function body: typein:1: function f(a) { if(a) return 1; typein:1: ..............................^
options("strict") is a toggle. Should it not be a toggle?
My bad, I thought it wasn't.
All of the options are toggles and are a pita but I've got work arounds for it. If you want to change it, please wait for a bit until I can get caught up on other things.
Blocks: 296661
OS: Mac OS X → All
Hardware: x86 → All
Assignee: general → nobody
Strict warning "does not always return a value" was removed in http://hg.mozilla.org/mozilla-central/rev/a470d0cbe3fa (bug 1046964)
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.