| Summary: | Incorrect error message in accidental function call | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | SheetJS <dev> |
| Component: | JavaScriptCore | Assignee: | Mark Lam <mark.lam> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | karlcow, mark.lam, webkit-bug-importer, ysuzuki |
| Priority: | P2 | Keywords: | BrowserCompat, InRadar |
| Version: | Safari 16 | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
This incorrect error message is an accidental by-product of a truncated error message. I'll be fixing this by compressing ExpressionInfo as well as changing it to no longer discard divot info. Pull request: https://github.com/WebKit/WebKit/pull/22880 Committed 273233@main (126d2027f1ce): <https://commits.webkit.org/273233@main> Reviewed commits have been landed. Closing PR #22880 and removing active labels. |
Reproduction: ```js console.log("hi") (async() => { console.log("hi"); console.log("hi"); console.log("hi"); console.log("hi"); console.log("hi"); console.log("hi"); })(); ``` This is interpreted as `console.log("hi")(/*...*/)();` and throws an error since `console.log("hi")` returns `undefined`. . V8 correctly diagnoses the error. Running in the Chrome DevTools shows the error: ``` Uncaught TypeError: console.log(...) is not a function ``` . Safari 16 and Bun 0.7.3 both misdiagnose the error: ``` TypeError: console.log is not a function. (In 'console.log("hi")', 'console.log' is undefined) ``` To be clear, `console.log` is not undefined in context. . This appears to be related to the size of the function body. For example, if one of the console calls is removed: ```js console.log("hi") (async() => { console.log("hi"); console.log("hi"); console.log("hi"); console.log("hi"); console.log("hi"); })(); ``` Safari and Bun both show correct error messages: ``` TypeError: console.log("hi") is not a function. (In 'console.log("hi") (async() => { console.log("hi"); console.log("hi"); console.log("hi"); console.log("hi"); console.log("hi"); })', 'console.log("hi") ' is undefined) ``` This message is correct: `console.log("hi")` is undefined.