WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
293557
Web Inspector: "Pretty print" removes required space in 1 .toString, producing invalid syntax
https://bugs.webkit.org/show_bug.cgi?id=293557
Summary
Web Inspector: "Pretty print" removes required space in 1 .toString, producin...
Andrei Iugai
Reported
2025-05-25 11:59:59 PDT
Steps to Reproduce --- 1. In a JavaScript file, add the following line: // 1.js var numberToString = uncurryThis(1 .toString); * Notice the space between "1" and ".toString", which is valid JavaScript syntax. 2. Load this code in Safari, open Web Inspector, and use the { } ("Pretty print") button. Actual Result --- Web Inspector reformats the code, removing the space and producing: // 1.js (formatted) var numberToString = uncurryThis(1.toString); This is invalid JavaScript syntax and causes a parsing error:
> SyntaxError: No identifiers allowed directly after numeric literal.
As a result, the code can no longer be executed. Expected Result --- Web Inspector should preserve the space, or rewrite the expression as "(1).toString", which is both valid and reliable JavaScript syntax. Other code formatters (such as Prettier and Biome) and Firefox DevTools' pretty-printer handle this case correctly. Impact --- - This bug breaks code for users of libraries such as "core-js", who use Local override and format button (see web.url.constructor.js:
https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/web.url.constructor.js#L38
). Many JavaScript projects use build tools like "esbuild" or "bun" that generate code with "1 .toString" (with a space). If a developer formats such code in Web Inspector, valid code may silently become invalid. - The issue is well known (core-js PR:
https://github.com/zloirock/core-js/pull/1368
) among JS toolchain maintainers. - Similar problems are present in Chromium DevTools; see Chromium bug #342488683:
https://issues.chromium.org/issues/342488683
. References --- * core-js: web.url.constructor.js, 1.0.toString usage:
https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/web.url.constructor.js#L38
* core-js PR #1072:
https://github.com/zloirock/core-js/pull/1072
* core-js PR #1368:
https://github.com/zloirock/core-js/pull/1368
* esbuild issue #3975:
https://github.com/evanw/esbuild/issues/3975
* Chromium bug #342488683:
https://issues.chromium.org/issues/342488683
Attachments
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2025-05-26 09:20:15 PDT
<
rdar://problem/152044607
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug