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

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

Closed
trxcllnt opened this issue Dec 21, 2018 · 5 comments
Assignees
Labels
bug internal-issue-created An internal Google issue has been created to track this GitHub issue triage-done Has been reviewed by someone on triage rotation.

Comments

@trxcllnt
Copy link

trxcllnt commented Dec 21, 2018

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)
@brad4d
Copy link
Contributor

brad4d commented Dec 21, 2018

Created internal Google issue b/121377660

@brad4d brad4d added bug triage-done Has been reviewed by someone on triage rotation. internal-issue-created An internal Google issue has been created to track this GitHub issue labels Dec 21, 2018
@brad4d
Copy link
Contributor

brad4d commented Dec 21, 2018

Thanks for pointing this out @trxcllnt

@brad4d
Copy link
Contributor

brad4d commented Jan 3, 2019

Internal tracking switched to issue http://b/122100368
I understand the problem and am working on a fix

@brad4d brad4d self-assigned this Jan 3, 2019
@lkjames
Copy link

lkjames commented Aug 6, 2019

Any updates on this? I'm having the same problem.

@brad4d
Copy link
Contributor

brad4d commented Aug 8, 2019

This was fixed in 83a8b02#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.

@brad4d brad4d closed this as completed Aug 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug internal-issue-created An internal Google issue has been created to track this GitHub issue triage-done Has been reviewed by someone on triage rotation.
Projects
None yet
Development

No branches or pull requests

3 participants