Destructuring assignments can return confusing error messages

RESOLVED WORKSFORME

Status

()

Core
JavaScript Engine
RESOLVED WORKSFORME
5 years ago
a month ago

People

(Reporter: miker, Unassigned)

Tracking

(Blocks: 1 bug)

Firefox Tracking Flags

(Not tracked)

Details

The following results in the error "values() is undefined":

function notvalues() {
  return [1, 2, 3];
}

let [x, y, z] = values();

This is to be expected but the following produces the same error even though values is defined:

function values() {
  return;
}

let [x, y, z] = values();
Maybe we could return something like "Unable to deconstruct return value."
(Assignee)

Updated

3 years ago
Assignee: general → nobody
Blocks: 622261

Comment 1

10 months ago
> function notvalues() {
>   return [1, 2, 3];
> }
> 
> let [x, y, z] = values();

current error message is "ReferenceError: values is not defined",
on today's nightly.

> function values() {
>   return;
> }
> 
> let [x, y, z] = values();

and "TypeError: values(...) is undefined" for this.

I think they're clear enough now.
Resolving as WFM per comment #1.
Status: NEW → RESOLVED
Last Resolved: a month ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.