Skip to content

Regression with destructuring assignments in JavaScript #20631

Closed

Description

@hectorm

I believe 5b63268 has introduced a regression with destructuring assignments in JavaScript.

I have found a minimal case that reproduces the error with the docker.io/emscripten/emsdk:3.1.48 image. It works fine in 3.1.47.

Version of emscripten/emsdk:

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.48 (e967e20b4727956a30592165a3c1cde5c67fa0a8)
clang version 18.0.0 (https://github.com/llvm/llvm-project a54545ba6514802178cf7cf1c1dd9f7efbf3cde7)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /emsdk/upstream/bin

Failing command line in full:

$ printf '%s\n' 'int main() { return 0; }' > ./in.c
$ printf '%s\n' '({a}) => a' > ./in.js
$ emcc -O2 ./in.c --pre-js ./in.js -o ./out.js
cache:INFO: generating system asset: symbol_lists/d069ff90f04e122eed9c73f5184186290656e2eb.json... (this will be cached in "/emsdk/upstream/emscripten/cache/symbol_lists/d069ff90f04e122eed9c73f5184186290656e2eb.json" for subsequent builds)
cache:INFO:  - ok
/emsdk/upstream/emscripten/tools/acorn-optimizer.js:25
    throw new Error(text);
    ^

Error: ObjectPattern
    at assert (/emsdk/upstream/emscripten/tools/acorn-optimizer.js:25:11)
    at /emsdk/upstream/emscripten/tools/acorn-optimizer.js:382:9
    at Array.forEach (<anonymous>)
    at handleFunction (/emsdk/upstream/emscripten/tools/acorn-optimizer.js:374:19)
    at Object.ArrowFunctionExpression (/emsdk/upstream/emscripten/tools/acorn-optimizer.js:456:9)
    at c (/emsdk/upstream/emscripten/tools/acorn-optimizer.js:85:20)
    at recursiveWalk (/emsdk/upstream/emscripten/tools/acorn-optimizer.js:87:5)
    at /emsdk/upstream/emscripten/tools/acorn-optimizer.js:83:38
    at maybeChild (/emsdk/upstream/emscripten/tools/acorn-optimizer.js:47:7)
    at visitChildren (/emsdk/upstream/emscripten/tools/acorn-optimizer.js:54:10)
emcc: error: '/emsdk/node/16.20.0_64bit/bin/node /emsdk/upstream/emscripten/tools/acorn-optimizer.js /tmp/emscripten_temp_ab537pq3/out.js JSDCE minifyWhitespace -o /tmp/emscripten_temp_ab537pq3/out.jso1.js' failed (returned 1)

Activity

  1. sbc100 commented on Nov 6, 2023

    @sbc100
    Collaborator

    Thanks for the report. That certainly does look like #20435

    It looks like we attempted to address it in #20435 (comment) but only for array-syntax destructuring.

  2. added 3 commits that reference this issue on Nov 6, 2023
    7c1bb63
    666dc41
    8f0faf1
  3. added a commit that references this issue on Nov 7, 2023
    01be543
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions