Skip to content

Fix support for JS destructuring in acorn optimizer pass - #20635

Merged
sbc100 merged 1 commit into
emscripten-core:mainfrom
sbc100:fix_acorn_destructuring
Nov 7, 2023
Merged

sbc100 merged 1 commit into
emscripten-core:mainfrom
sbc100:fix_acorn_destructuring

Conversation

@sbc100

@sbc100 sbc100 commented Nov 6, 2023

Copy link
Copy Markdown
Collaborator

Fixes: #20631

@sbc100
sbc100 requested review from RReverser and kripken November 6, 2023 23:16
@sbc100
sbc100 force-pushed the fix_acorn_destructuring branch from 7c1bb63 to 666dc41 Compare November 6, 2023 23:19
Comment thread tools/acorn-optimizer.js Resolved
@sbc100
sbc100 force-pushed the fix_acorn_destructuring branch from 666dc41 to 8f0faf1 Compare November 6, 2023 23:37
@RReverser

Copy link
Copy Markdown
Collaborator

Looks good, but just one more nit: looks like this handling (unsurprisingly, I suppose, since they're very similar) overlaps quite a bit with VariableDeclarator handling a little further below. Is it possible to merge them / reuse functionality?

@sbc100

sbc100 commented Nov 7, 2023

Copy link
Copy Markdown
Collaborator Author

Looks good, but just one more nit: looks like this handling (unsurprisingly, I suppose, since they're very similar) overlaps quite a bit with VariableDeclarator handling a little further below. Is it possible to merge them / reuse functionality?

Perhaps, but since this code is not really my area of expertise I don't (currently) feel very confident doing such refactorings.

@RReverser

Copy link
Copy Markdown
Collaborator

Sure. It seems like it would be fairly easy extraction into a single function, but it's fair if you want to leave that for later.

@sbc100

sbc100 commented Nov 7, 2023

Copy link
Copy Markdown
Collaborator Author

I did take quick look, but VariableDeclarator handler looks like it doesn't recursively call itself... perhaps it should do, but I'm unsure enough about this code I'd rather leave refactoring like that to later.. or someone who has a better grasp of it.

@sbc100
sbc100 enabled auto-merge (squash) November 7, 2023 00:24
@RReverser

Copy link
Copy Markdown
Collaborator

I did take quick look, but VariableDeclarator handler looks like it doesn't recursively call itself

Yeah I probably should've said it's very similar to what this function did before this PR. As in, both just walked over a flat list, except VariableDeclarator already supported ObjectPattern/ArrayPattern and this one didn't.

Now this one supports those patterns as well as recursive handling, but VariableDeclarator doesn't do recursive walk yet.

Leaving for later sounds good, just wanted to describe how / why I arrived at suggestion to merge them for consistent behaviour.

@sbc100
sbc100 merged commit 01be543 into emscripten-core:main Nov 7, 2023
@sbc100
sbc100 deleted the fix_acorn_destructuring branch November 7, 2023 00:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regression with destructuring assignments in JavaScript

2 participants