jsfiddle / jsfiddle-users

Discussions, issues and docs for JSFiddle.
https://jsfiddle.net
314 stars 114 forks source link

Tidy breaks all conditional chaining and nullish coalescing operators. #1870

Closed mplungjan closed 2 months ago

mplungjan commented 4 months ago

If I press tidy, jsFiddle breaks all conditional chaining and nullish coalescing operators. If I change to JS1.7 as suggested in (https://github.com/jsfiddle/jsfiddle-users/issues/1771) I just do not get the error shown, but the script is still broken.

?. ?? ??= &&= ||=

Valid JS

image

Clicking Tidy breaks it

image

Using JS 1.7 hides the error

image
oskarkrawczyk commented 2 months ago

Refactored the way tidy works, from what I can see this issue is no more.

mplungjan commented 2 months ago

Where can I test? This one I just made still shows the issue https://jsfiddle.net/mplungjan/7ergahun/

oskarkrawczyk commented 2 months ago

Perhaps a caching issue - I've additionally purged cache on CloudFlare, perhaps this will help.

mplungjan commented 2 months ago

Ok, that worked - however I get a parsing error on the otherwise correct ??=

https://jsfiddle.net/mplungjan/Lp2v1gcz/

let a = x?.y; let b = 0 ?? 42; let z ??= []; // parsing error let c &&= 2; let d ||= 3;

oskarkrawczyk commented 2 months ago

Not much I can do about that since it's a browser thing. Safari and Firefox will throw a SyntaxError.

EDIT: From what I can tell on MDN, the line let z ??= [] is imply not valid syntax – https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing_assignment