Bug 256245 - Improve error message for code like "var {a} = undefined;"
Summary: Improve error message for code like "var {a} = undefined;"
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-05-02 22:31 PDT by Jarred Sumner
Modified: 2023-05-09 22:32 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jarred Sumner 2023-05-02 22:31:23 PDT
Currently, the following code:

> await Promise.resolve(undefined).then(({default: a}) => a.true())

Produces the following messages:

> TypeError: Right side of assignment cannot be destructured

Instead, something closer to V8's message would be clearer:

> TypeError: Cannot read properties of undefined


It looks like the message is generated here:

https://github.com/WebKit/WebKit/blob/8c684cfbe8afa5cb7eea0e46408cbdd31e920ba1/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp#L5607

It looks like the object can be at least null or undefined when this error is thrown, but it seems like most of these error messages are statically allocated which makes it harder to change them?
Comment 1 Radar WebKit Bug Importer 2023-05-09 22:32:18 PDT
<rdar://problem/109136179>