Closed Bug 1127629 Opened 9 years ago Closed 9 years ago

"<blah> is not a function" doesn't work for `void ...` expressions

Categories

(Core :: JavaScript Engine, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla39
Tracking Status
firefox39 --- fixed

People

(Reporter: fitzgen, Assigned: evilpie)

Details

Attachments

(1 file, 1 obsolete file)

When you try and call a variable that is not a function as a function, you get a helpful message:

  > f = undefined
  undefined
  > f()
  TypeError: f is not a function

For some expressions, you get a helpful message too:

  > function getF() {}
  undefined
  > getF()()
  TypeError: getF(...) is not a function

However, if you have a `void ..` expression, then the error message sucks:

  > (void 2)()
  TypeError: undefined is not a function

I'd expect it to be something like "TypeError: (void ...) is not a function".

Are there other cases that produce bad error messages as well?
This is the expression decompiler, see ExpressionDecompiler::decompilePC.

It has some generic code for unary and binary operators, but we don't have a token string for JSOP_VOID in Opcodes.h, that's probably why it doesn't work here. If we added one it'd probably decompile to void(2)...
Attached patch void-decompile (obsolete) — Splinter Review
Or do we always want to decompile, void 0 as `(void 0)`?
Attachment #8567719 - Flags: review?(jdemooij)
Attached patch void-decompileSplinter Review
Assignee: nobody → evilpies
Attachment #8567719 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #8567719 - Flags: review?(jdemooij)
Attachment #8567720 - Flags: review?(jdemooij)
Comment on attachment 8567720 [details] [diff] [review]
void-decompile

Review of attachment 8567720 [details] [diff] [review]:
-----------------------------------------------------------------

Nice.
Attachment #8567720 - Flags: review?(jdemooij) → review+
There was some problem with my test and --ion-eager, so I changed it to be more specific.
https://hg.mozilla.org/mozilla-central/rev/2d7d8a404d0a
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla39
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: