Skip to content

Internal error with let inside while loop #1124

Closed

Description

@ochafik

This simple code:

while (true) {
  let x = null;
  function f() {
    x();
  }
}

Gives the following trace (cmd line args: --language_in=ECMASCRIPT6_STRICT -O SIMPLE):

INTERNAL COMPILER ERROR.
Please report this problem.

Invalid attempt to remove node: NAME $jscomp$loop$0 3 [source_file: bug_closure.js] of CALL 3 [free_call: 1] [source_file: bug_closure.js]
  Node(NAME $jscomp$loop$0): bug_closure.js:3:2
  function f() {
  Parent(CALL): bug_closure.js:3:2
  function f() {

    at com.google.javascript.jscomp.NodeUtil.removeChild(NodeUtil.java:2293)
    at com.google.javascript.jscomp.UnreachableCodeElimination$EliminationPass.removeNode(UnreachableCodeElimination.java:261)
    at com.google.javascript.jscomp.UnreachableCodeElimination$EliminationPass.removeDeadExprStatementSafely(UnreachableCodeElimination.java:251)
    at com.google.javascript.jscomp.UnreachableCodeElimination$EliminationPass.visit(UnreachableCodeElimination.java:104)
    at com.google.javascript.jscomp.NodeTraversal.traverseBranch(NodeTraversal.java:609)
    at com.google.javascript.jscomp.NodeTraversal.traverseBranch(NodeTraversal.java:603)
    at com.google.javascript.jscomp.NodeTraversal.traverseBlockScope(NodeTraversal.java:652)
    at com.google.javascript.jscomp.NodeTraversal.traverseBranch(NodeTraversal.java:597)
    at com.google.javascript.jscomp.NodeTraversal.traverseBlockScope(NodeTraversal.java:652)
    at com.google.javascript.jscomp.NodeTraversal.traverseBranch(NodeTraversal.java:597)
    at com.google.javascript.jscomp.NodeTraversal.traverseBranch(NodeTraversal.java:603)
    at com.google.javascript.jscomp.NodeTraversal.traverseBranch(NodeTraversal.java:603)
    at com.google.javascript.jscomp.NodeTraversal.traverse(NodeTraversal.java:295)
    at com.google.javascript.jscomp.NodeTraversal.traverseEs6(NodeTraversal.java:560)
    at com.google.javascript.jscomp.UnreachableCodeElimination$1.enterFunction(UnreachableCodeElimination.java:81)

Note that it works fine with var instead of let.

Activity

  1. MatrixFrog commented on Sep 9, 2015

    @MatrixFrog
    Contributor

    This might be another one that will be fixed with --language_out=ES5?

  2. Dominator008 commented on Sep 9, 2015

    @Dominator008
    Contributor

    @MatrixFrog Seems like it's a bug in Es6ToEs3RewriteBlockScopedDeclaration

  3. self-assigned this
    on Sep 9, 2015
  4. ochafik commented on Sep 9, 2015

    @ochafik
    Author

    (neither --language_out=ES5 nor --language_out=ECMASCRIPT5_STRICT help here, unfortunately)

  5. added 2 commits that reference this issue on Sep 9, 2015
    725ebdc
    a8e0d3f
  6. ochafik commented on Sep 12, 2015

    @ochafik
    Author

    Thanks a lot guys!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions