Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terser "cannot read property print of undefined" #14525

Closed
hoodmane opened this issue Jun 23, 2021 · 4 comments
Closed

Terser "cannot read property print of undefined" #14525

hoodmane opened this issue Jun 23, 2021 · 4 comments

Comments

@hoodmane
Copy link
Contributor

hoodmane commented Jun 23, 2021

I've been getting the following error during linking for the last few days. It occurs both with emsdk version 20.0.16 and 20.0.24.

/src/emsdk/emsdk/upstream/emscripten/third_party/terser/terser.js:6956
        self.right.print(output);
                   ^

TypeError: Cannot read property 'print' of undefined
    at /src/emsdk/emsdk/upstream/emscripten/third_party/terser/terser.js:6956:20
    at doit (/src/emsdk/emsdk/upstream/emscripten/third_party/terser/terser.js:5999:13)
    at AST_Binary.<anonymous> (/src/emsdk/emsdk/upstream/emscripten/third_party/terser/terser.js:6006:13)
    at /src/emsdk/emsdk/upstream/emscripten/third_party/terser/terser.js:6857:22
    at Array.forEach (<anonymous>)
    at /src/emsdk/emsdk/upstream/emscripten/third_party/terser/terser.js:6855:23
    at Object.with_parens (/src/emsdk/emsdk/upstream/emscripten/third_party/terser/terser.js:5765:19)
    at /src/emsdk/emsdk/upstream/emscripten/third_party/terser/terser.js:6854:16
    at doit (/src/emsdk/emsdk/upstream/emscripten/third_party/terser/terser.js:5999:13)
    at AST_Call.<anonymous> (/src/emsdk/emsdk/upstream/emscripten/third_party/terser/terser.js:6006:13)
em++: error: '/src/emsdk/emsdk/node/14.15.5_64bit/bin/node /src/emsdk/emsdk/upstream/emscripten/tools/acorn-optimizer.js /tmp/emscripten_temp_sfcafjzx/pyodide.asm.js

I can make it go away by commenting out the following lines in the definition of phase_binaryen in emcc.py:

      final_js = building.minify_wasm_js(js_file=final_js,
                                          wasm_file=wasm_target,
                                          expensive_optimizations=will_metadce(),
                                          minify_whitespace=minify_whitespace() and not options.use_closure_compiler,
                                          debug_info=intermediate_debug_info)
@kripken
Copy link
Member

kripken commented Jun 24, 2021

Perhaps you are hitting a bug in terser. If this isn't a regression from an earlier version, can you provide a testcase?

@kleisauke
Copy link
Collaborator

Noticed the same when testing #11066 (comment). Here's a reduced test case:

#include <emscripten.h>

EM_JS(int, test, (), {
  var bigint = 1 & 0xffffffffn;
  //var bigint = 1 & BigInt(0xffffffff);
  return bigint;
});

int main() {
    test();
    return 0;
}
emcc -O2 test.c

Looks like it's failing on that BigInt's n-suffix.

@hoodmane
Copy link
Contributor Author

Thanks @kleisauke! I hadn't realized it was the BigInt suffix causing the trouble. For now I can just avoid that syntax.

kleisauke added a commit to kleisauke/libffi-emscripten that referenced this issue Jun 25, 2021
@kleisauke
Copy link
Collaborator

This looks like a duplicate of issue #13297.

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

No branches or pull requests

3 participants