Closed trueadm closed 5 years ago
i am facing something similar
DESTRUCTURING_LHS 23 [length: 20] [source_file: src/polyfills/object-assign.js] is not a string node
Node(CONST): src/polyfills/object-assign.js:23:0
const {prototype} = Object;
Parent(SCRIPT): src/polyfills/object-assign.js:17:0
const Object = {
at com.google.javascript.rhino.Node.getString(Node.java:1113)
at org.ampproject.AmpPass.maybeReplaceRValueInVar(Unknown Source)
at org.ampproject.AmpPass.visit(Unknown Source)
at com.google.javascript.jscomp.NodeTraversal.traverseBranch(NodeTraversal.java:769)
at com.google.javascript.jscomp.NodeTraversal.traverseChildren(NodeTraversal.java:840)
at com.google.javascript.jscomp.NodeTraversal.handleScript(NodeTraversal.java:721)
at com.google.javascript.jscomp.NodeTraversal.traverseBranch(NodeTraversal.java:746)
at com.google.javascript.jscomp.NodeTraversal.traverseChildren(NodeTraversal.java:840)
at com.google.javascript.jscomp.NodeTraversal.traverseBranch(NodeTraversal.java:765)
at com.google.javascript.jscomp.NodeTraversal.traverse(NodeTraversal.java:305)
at com.google.javascript.jscomp.NodeTraversal.traverseEs6(NodeTraversal.java:680)
at org.ampproject.AmpPass.hotSwapScript(Unknown Source)
at org.ampproject.AmpPass.process(Unknown Source)
at com.google.javascript.jscomp.Compiler.process(Compiler.java:1083)
at com.google.javascript.jscomp.Compiler.runCustomPasses(Compiler.java:1116)
at com.google.javascript.jscomp.Compiler.check(Compiler.java:1072)
at com.google.javascript.jscomp.Compiler.performChecksAndTranspilation(Compiler.java:866)
at com.google.javascript.jscomp.Compiler.access$000(Compiler.java:102)
at com.google.javascript.jscomp.Compiler$2.call(Compiler.java:800)
at com.google.javascript.jscomp.Compiler$2.call(Compiler.java:797)
at com.google.javascript.jscomp.CompilerExecutor$2.call(CompilerExecutor.java:101)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.UnsupportedOperationException: DESTRUCTURING_LHS 23 [length: 20] [source_file: src/polyfills/object-assign.js] is not a string node
... 25 more
for code like:
const {hasOwnProperty} = Object.prototype;
code link: https://github.com/ampproject/amphtml/blob/master/src/polyfills/object-assign.js#L17
Created internal Google issue b/119638231
@prateekbh in your case the failure is happening in code that is not part of closure-compiler.
AmpPass
needs to be updated to understand how to handle destructuring assignments.
If this failure has only recently started happening, that is because we recently moved the transpilation of destructuring assignments later in the compilation process. Probably it previously happened before the exection of AmpPass
, so it never saw any destructuring code, but has now been moved after.
@trueadm it looks like we need to update AnalyzePrototypeProperties
to make sure it understands computed properties.
We haven't done that yet, because in the closure-compiler code it is only used within CrossChunkCodeMotion
, which is a pass that runs after all language features above ES5 have been removed from the code. Apparently AmpPass
also uses it. See my comment above.
We will be fixing AnalyzePrototypeProperties
in the next quarter, because we need to make CrossChunkCodeMotion
work for language output > ES5, but we can't do anything about the AmpPass
.
@trueadm correction: I somehow thought I was looking at your stack trace when I was still looking at the one from @prateekbh
I see your failure is in CrossChunkCodeMotion
.
That pass should have already been updated to handle destructuring.
Looks like we failed to notice the issue with AnalyzePrototypeProperties
when we enabled CrossChunkCodeMotion
for language output levels > ES5.
We'll fix AnalyzePrototypeProperties
.
@trueadm I've submitted a fix for the crash internally. It will be pushed to GitHub tomorrow.
@lauraharker Thank you :)
Given the current test case:
The following error is thrown: