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)

enhancement

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.)
Shouldn't it be "is not callable" (when not undefined or null)? Non-functions can be callable.
OS: Mac OS X → All
Hardware: x86 → All
Assignee: general → nobody
Blocks: jserror
Priority: -- → P5
Flags: needinfo?(arai.unmht)
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'
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
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)

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
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: