Open
Bug 418573
Opened 18 years ago
Updated 3 years ago
Say "is undefined" or "is null" instead of "is not a function" when appropriate
Categories
(Core :: JavaScript Engine, enhancement, P5)
Core
JavaScript Engine
Tracking
()
ASSIGNED
People
(Reporter: jruderman, Assigned: arai)
References
(Blocks 1 open bug)
Details
(Keywords: testcase)
Attachments
(1 file)
js> ({}).b()
typein:14: TypeError: {}.b is not a function
js> ({}).b.c
typein:16: TypeError: {}.b is undefined
I think we should use the more specific error message "is undefined" for attempted function calls too. (The old message "has no properties", which was replaced by "is null" / "is undefined" in bug 353116, wouldn't have made sense in this context.)
Comment 1•18 years ago
|
||
Shouldn't it be "is not callable" (when not undefined or null)? Non-functions can be callable.
Updated•15 years ago
|
OS: Mac OS X → All
Hardware: x86 → All
Updated•12 years ago
|
Assignee: general → nobody
| Assignee | ||
Updated•8 years ago
|
Priority: -- → P5
| Assignee | ||
Updated•8 years ago
|
Flags: needinfo?(arai.unmht)
| Assignee | ||
Comment 2•8 years ago
|
||
I'm wondering about the wording...
Safari
> ({}).b()
< TypeError: ({}).b is not a function. (In '({}).b()', '({}).b' is undefined)
Google Chrome
> ({}).b()
VM55:1 Uncaught TypeError: {}.b is not a function
at <anonymous>:1:6
Edge
> ({}).b()
Object doesn't support property or method 'b'
| Assignee | ||
Comment 3•8 years ago
|
||
WIP patch:
js> ({}).b()
typein:1:6 TypeError: (intermediate value).b is undefined, not callable
the behavior seems to be changed at some point and we don't say ({}) for this case (even without patch)
other case:
js> ({b: null}).b()
typein:1:13 TypeError: ({b:null}).b is null, not callable
if the decompiled string is null/undefined, the previous message is used:
js> null()
typein:4:1 TypeError: null is not a function
js> undefined()
typein:5:1 TypeError: undefined is not a function
| Assignee | ||
Comment 4•8 years ago
|
||
WIP patch here.
there are more places that uses JSMSG_NOT_FUNCTION/JSMSG_NOT_CONSTRUCTOR.
I'll check them later.
Assignee: nobody → arai.unmht
Status: NEW → ASSIGNED
Flags: needinfo?(arai.unmht)
Comment 5•6 years ago
|
||
Chrome also uses "is not a function". I suspect most JS developers don't really know the difference between callable and a function.
> ({}).b()
TypeError: {}.b is not a function
Updated•4 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•