question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Compiler crashes on async function with default argument compiling esnext -> es5

See original GitHub issue

Sample code:

// tmp.js
class Foo {
    constructor(x) { this.x = x }
    async doThing(y = this.x) { (y !== false) && console.log('blah'); }
}
(async () => await new Foo(true).doThing())();

Crashes with the following error:

$ java -jar node_modules/google-closure-compiler-java/compiler.jar --version
Closure Compiler (http://github.com/google/closure-compiler)
Version: v20181210
Built on: 2018-12-12 22:32

$ java -jar node_modules/google-closure-compiler-java/compiler.jar \
  --language_in=ECMASCRIPT_NEXT \
  --language_out=ECMASCRIPT5 \
  --js=tmp.js

java.lang.NullPointerException: NAME $jscomp$async$this 3 [length: 4] [source_file: tmp.js]
	at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:895)
	at com.google.javascript.jscomp.RemoveUnusedCode.getVarForNameNode(RemoveUnusedCode.java:669)
	at com.google.javascript.jscomp.RemoveUnusedCode.traverseNameNode(RemoveUnusedCode.java:531)
	at com.google.javascript.jscomp.RemoveUnusedCode.traverseNode(RemoveUnusedCode.java:406)
	at com.google.javascript.jscomp.RemoveUnusedCode.traverseGetProp(RemoveUnusedCode.java:442)
	at com.google.javascript.jscomp.RemoveUnusedCode.traverseNode(RemoveUnusedCode.java:411)
	at com.google.javascript.jscomp.RemoveUnusedCode.traverseChildren(RemoveUnusedCode.java:1118)
	at com.google.javascript.jscomp.RemoveUnusedCode.traverseNode(RemoveUnusedCode.java:415)
	at com.google.javascript.jscomp.RemoveUnusedCode.access$1200(RemoveUnusedCode.java:90)
	at com.google.javascript.jscomp.RemoveUnusedCode$Continuation.apply(RemoveUnusedCode.java:1536)
	at com.google.javascript.jscomp.RemoveUnusedCode.traverseAndRemoveUnusedReferences(RemoveUnusedCode.java:249)
	at com.google.javascript.jscomp.RemoveUnusedCode.process(RemoveUnusedCode.java:228)
	at com.google.javascript.jscomp.PhaseOptimizer$NamedPass.process(PhaseOptimizer.java:310)
	at com.google.javascript.jscomp.PhaseOptimizer$Loop.process(PhaseOptimizer.java:455)
	at com.google.javascript.jscomp.PhaseOptimizer.process(PhaseOptimizer.java:231)
	at com.google.javascript.jscomp.Compiler.performOptimizations(Compiler.java:2435)
	at com.google.javascript.jscomp.Compiler.lambda$stage2Passes$1(Compiler.java:849)
	at com.google.javascript.jscomp.CompilerExecutor$2.call(CompilerExecutor.java:102)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:844)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
brad4dcommented, Dec 21, 2018

Thanks for pointing this out @trxcllnt

0reactions
brad4dcommented, Aug 8, 2019

This was fixed in https://github.com/google/closure-compiler/commit/83a8b02c384abda8db5b57d46c1805f592ccd77a#diff-8766342281b3b4b5ee20a57d7f5b061d

I’m not sure why this issue wasn’t automatically closed by the “Fixes” comment on that commit.

If you are having a problem with the current version of closure-compiler, please file a new issue with instructions for reproducing the problem. Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Typescript express not working after switching to esnext
I'm working on a react typescript application. Because of 'top level await' issues, I want to change my target and module to 'es2017'...
Read more >
Crash on async function calls - Compiler - Swift Forums
Hello everyone! I stumbled upon an async issues that seem too straightforward to actually be true. The problems. Async IBAction crash.
Read more >
Compiler Options - Microsoft Open Source
Changes the function called in .js files when compiling JSX Elements. The most common change is to use "h" or "preact.h" instead of...
Read more >
TSConfig Reference - Docs on every TSConfig option
A TSConfig file in a directory indicates that the directory is the root of a TypeScript or JavaScript project... Compiler Options. Top Level....
Read more >
Compiling async/await to ES3/ES5 in TypeScript - Marius Schulz
The compiler transformed asynchronous functions to generator functions using yield . However, this meant that you couldn't target ES3 or ES5 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found