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

NPE during visit of misconstructed AST structure #341

Closed
bwilkerson opened this issue Nov 4, 2011 · 1 comment
Closed

NPE during visit of misconstructed AST structure #341

bwilkerson opened this issue Nov 4, 2011 · 1 comment
Assignees

Comments

@bwilkerson
Copy link
Member

The following input (between the dotted lines):


class test {
  factory test<X extneds List>(){}
}
//
typedef Map Fox<T1 extends Map>(List input);
class HashMapImplementation<K extends Hashable, V> implements HashMap<K, V> {}
/
/
class Fooa {
  final Bara<Fooa> bar = const Bara/* <Fooa> Workaround bug #­322 */();
}

class Bara<T extends Fooa> {
  const Bara();
}

main1() {
  print(new Fooa());
}
/*********/
class C1<Q> {
  Q x;
  C1(Q x) { this.x = x; }
}

class C2<Q> {
  Q x;
  C2(this.x) {}
}

main2() {
  C1<int> c1 = new C1<int>(0);
  C2<int> c2 = new C2<int>(1);
}
/*********/
class Foo {
  final Bar<Foo> bar = const Bar<Foo>();
}

class Bar<T extends Foo> {
  const Bar();
}

main3() {
  print(new Foo());
}
/*********/

class X {
  static final num MAX = 0;
  num yc,xc;
  mth() {
    xc = yc = MAX;
    xc.abs();
    num f = MAX;
  }
}
class Y {
  String x="hi";
  mth() {
    x.length;
    int n = 0;
    x.charCodeAt(n);
  }
}
class Z {
  Map m = const Map();
  mth() {
    var x = new List.from(['a']);
  }
}
class A {
  int x;
  mth() {
    int y = this.x;
  }
}
class B1 {
  B1();
  x(){}
}
class B2 extends B1 {
  B2() { super.x();}
}
class C {
  mth(Map x, q) {}
  mtf(q, Map x) {}
  m() { for (int i = 0; i < 5; i++); A x;}
}
class D {
  f(){} g(){f(/f/);}
}
class E {
  int x; mth() {var y = x;}
}
class F {
  var x = false;
}


will cause the parser to produce an AST structure containing a DartBinaryExpression whose arg1 is null. Obviously this AST structure should never be produced. Below is the stack trace from the NPE in case it's useful.


!ENTRY com.google.dart.tools.ui 4 2 2011-11-04 08:40:43.130
!MESSAGE Problems occurred when invoking code from plug-in: "com.google.dart.tools.ui".
!STACK 0
java.lang.NullPointerException
    at com.google.dart.compiler.ast.DartBinaryExpression.visitChildren(DartBinaryExpression.java:66)
    at com.google.dart.compiler.ast.DartNodeTraverser.visitNode(DartNodeTraverser.java:54)
    at com.google.dart.compiler.ast.DartNodeTraverser.visitExpression(DartNodeTraverser.java:67)
    at com.google.dart.compiler.ast.DartNodeTraverser.visitBinaryExpression(DartNodeTraverser.java:111)
    at com.google.dart.compiler.ast.DartBinaryExpression.accept(DartBinaryExpression.java:72)
    at com.google.dart.compiler.ast.DartMapLiteralEntry.visitChildren(DartMapLiteralEntry.java:39)
    at com.google.dart.compiler.ast.DartNodeTraverser.visitNode(DartNodeTraverser.java:54)
    at com.google.dart.compiler.ast.DartNodeTraverser.visitMapLiteralEntry(DartNodeTraverser.java:271)
    at com.google.dart.compiler.ast.DartMapLiteralEntry.accept(DartMapLiteralEntry.java:45)
    at com.google.dart.compiler.ast.DartNodeTraverser.visit(DartNodeTraverser.java:413)
    at com.google.dart.compiler.ast.DartMapLiteral.visitChildren(DartMapLiteral.java:38)
    at com.google.dart.compiler.ast.DartNodeTraverser.visitNode(DartNodeTraverser.java:54)
    at com.google.dart.compiler.ast.DartNodeTraverser.visitExpression(DartNodeTraverser.java:67)
    at com.google.dart.compiler.ast.DartNodeTraverser.visitMapLiteral(DartNodeTraverser.java:266)
    at com.google.dart.compiler.ast.DartMapLiteral.accept(DartMapLiteral.java:43)
    at com.google.dart.compiler.ast.DartMapLiteralEntry.visitChildren(DartMapLiteralEntry.java:39)
    at com.google.dart.compiler.ast.DartNodeTraverser.visitNode(DartNodeTraverser.java:54)
    at com.google.dart.compiler.ast.DartNodeTraverser.visitMapLiteralEntry(DartNodeTraverser.java:271)
    at com.google.dart.compiler.ast.DartMapLiteralEntry.accept(DartMapLiteralEntry.java:45)
    at com.google.dart.compiler.ast.DartNodeTraverser.visit(DartNodeTraverser.java:413)
    at com.google.dart.compiler.ast.DartMapLiteral.visitChildren(DartMapLiteral.java:38)
    at com.google.dart.compiler.ast.DartNodeTraverser.visitNode(DartNodeTraverser.java:54)
    at com.google.dart.compiler.ast.DartNodeTraverser.visitExpression(DartNodeTraverser.java:67)
    at com.google.dart.compiler.ast.DartNodeTraverser.visitMapLiteral(DartNodeTraverser.java:266)
    at com.google.dart.compiler.ast.DartMapLiteral.accept(DartMapLiteral.java:43)
    at com.google.dart.compiler.ast.DartBinaryExpression.visitChildren(DartBinaryExpression.java:67)
    at com.google.dart.compiler.ast.DartNodeTraverser.visitNode(DartNodeTraverser.java:54)
    at com.google.dart.compiler.ast.DartNodeTraverser.visitExpression(DartNodeTraverser.java:67)
    at com.google.dart.compiler.ast.DartNodeTraverser.visitBinaryExpression(DartNodeTraverser.java:111)
    at com.google.dart.compiler.ast.DartBinaryExpression.accept(DartBinaryExpression.java:72)
    at com.google.dart.compiler.ast.DartExprStmt.visitChildren(DartExprStmt.java:31)
    at com.google.dart.compiler.ast.DartNodeTraverser.visitNode(DartNodeTraverser.java:54)
    at com.google.dart.compiler.ast.DartNodeTraverser.visitStatement(DartNodeTraverser.java:71)
    at com.google.dart.compiler.ast.DartNodeTraverser.visitExprStmt(DartNodeTraverser.java:191)
    at com.google.dart.compiler.ast.DartExprStmt.accept(DartExprStmt.java:36)
    at com.google.dart.compiler.ast.DartNodeTraverser.visit(DartNodeTraverser.java:413)
    at com.google.dart.compiler.ast.DartBlock.visitChildren(DartBlock.java:44)
    at com.google.dart.compiler.ast.DartNodeTraverser.visitNode(DartNodeTraverser.java:54)
    at com.google.dart.compiler.ast.DartNodeTraverser.visitStatement(DartNodeTraverser.java:71)
    at com.google.dart.compiler.ast.DartNodeTraverser.visitBlock(DartNodeTraverser.java:116)
    at com.google.dart.compiler.ast.DartBlock.accept(DartBlock.java:49)
    at com.google.dart.compiler.ast.DartFunction.visitChildren(DartFunction.java:57)
    at com.google.dart.compiler.ast.DartNodeTraverser.visitNode(DartNodeTraverser.java:54)
    at com.google.dart.compiler.ast.DartNodeTraverser.visitFunction(DartNodeTraverser.java:216)
    at com.google.dart.compiler.ast.DartFunction.accept(DartFunction.java:66)
    at com.google.dart.compiler.ast.DartMethodDefinition.visitChildren(DartMethodDefinition.java:85)
    at com.google.dart.compiler.ast.DartMethodDefinition$DartMethodWithInitializersDefinition.visitChildren(DartMethodDefinition.java:121)
    at com.google.dart.compiler.ast.DartNodeTraverser.visitNode(DartNodeTraverser.java:54)
    at com.google.dart.compiler.ast.DartNodeTraverser.visitDeclaration(DartNodeTraverser.java:87)
    at com.google.dart.compiler.ast.DartNodeTraverser.visitClassMember(DartNodeTraverser.java:91)
    at com.google.dart.compiler.ast.DartNodeTraverser.visitMethodDefinition(DartNodeTraverser.java:276)
    at com.google.dart.compiler.ast.DartMethodDefinition.accept(DartMethodDefinition.java:90)
    at com.google.dart.tools.core.internal.model.CompilationUnitImpl$CompilationUnitStructureBuilder.visitClass(CompilationUnitImpl.java:189)
    at com.google.dart.tools.core.internal.model.CompilationUnitImpl$CompilationUnitStructureBuilder.visitClass(CompilationUnitImpl.java:1)
    at com.google.dart.compiler.ast.DartClass.accept(DartClass.java:175)
    at com.google.dart.compiler.ast.DartNodeTraverser.visit(DartNodeTraverser.java:413)
    at com.google.dart.compiler.ast.DartUnit.visitChildren(DartUnit.java:99)
    at com.google.dart.compiler.ast.DartNodeTraverser.visitNode(DartNodeTraverser.java:54)
    at com.google.dart.compiler.ast.DartNodeTraverser.visitUnit(DartNodeTraverser.java:391)
    at com.google.dart.tools.core.internal.model.CompilationUnitImpl$CompilationUnitStructureBuilder.visitUnit(CompilationUnitImpl.java:338)
    at com.google.dart.tools.core.internal.model.CompilationUnitImpl$CompilationUnitStructureBuilder.visitUnit(CompilationUnitImpl.java:1)
    at com.google.dart.compiler.ast.DartUnit.accept(DartUnit.java:107)
    at com.google.dart.tools.core.internal.model.CompilationUnitImpl.buildStructure(CompilationUnitImpl.java:1449)

This issue was closed.
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

2 participants