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

Resolver exception from invalid code #400

Closed
stevemessick opened this issue Nov 9, 2011 · 3 comments
Closed

Resolver exception from invalid code #400

stevemessick opened this issue Nov 9, 2011 · 3 comments
Assignees

Comments

@stevemessick
Copy link
Contributor

Code completion on the following code causes an exception. The completion point is line 29 immediately after the 't' of 'const' (no space) in class C1. The exception refers to class Bar, which is defined on line 46, so presumably a large amount of text was incorrectly parsed. Prior to the addition of 'const ' the file compiled with no errors. The stack trace follows the code. Note that a significantly different AST is created if the space following 'const' is deleted. Changing 'const' to 'const Map();' compiles without error. Changing to 'const M' and attempting completion following the 'M' causes a similar exception.

class test {
  factory test<X extends List>() {}
}
interface I<T extends Map> factory Ci<T> {
  
}
class Ci<S> implements I<Map> {
  factory I<R>() {} // <R> is not optional and must be compatible with S.
 }

//
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; const }
}

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(T k);
  T m(T a, T b){}
  T f = null;
}

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;
}

com.google.dart.compiler.InternalCompilerException: Unexpected element Bar kind: CLASSevaluating type for compile-time constant expression.
    at com.google.dart.compiler.resolver.CompileTimeConstVisitor.getMostSpecificType(CompileTimeConstVisitor.java:396)
    at com.google.dart.compiler.resolver.CompileTimeConstVisitor.visitBinaryExpression(CompileTimeConstVisitor.java:109)
    at com.google.dart.compiler.resolver.CompileTimeConstVisitor.visitBinaryExpression(CompileTimeConstVisitor.java:1)
    at com.google.dart.compiler.ast.DartBinaryExpression.accept(DartBinaryExpression.java:72)
    at com.google.dart.compiler.resolver.Resolver$ResolveElementsVisitor.checkConstantExpression(Resolver.java:349)
    at com.google.dart.compiler.resolver.Resolver$ResolveElementsVisitor.visitNewExpression(Resolver.java:883)
    at com.google.dart.compiler.resolver.Resolver$ResolveElementsVisitor.visitNewExpression(Resolver.java:1)
    at com.google.dart.compiler.ast.DartNewExpression.accept(DartNewExpression.java:67)
    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.resolver.Resolver$ResolveElementsVisitor.visitBlock(Resolver.java:477)
    at com.google.dart.compiler.resolver.Resolver$ResolveElementsVisitor.visitBlock(Resolver.java:1)
    at com.google.dart.compiler.ast.DartBlock.accept(DartBlock.java:49)
    at com.google.dart.compiler.resolver.Resolver$ResolveElementsVisitor.resolve(Resolver.java:289)
    at com.google.dart.compiler.resolver.Resolver$ResolveElementsVisitor.visitMethodDefinition(Resolver.java:330)
    at com.google.dart.compiler.resolver.Resolver$ResolveElementsVisitor.visitMethodDefinition(Resolver.java:1)
    at com.google.dart.compiler.ast.DartMethodDefinition.accept(DartMethodDefinition.java:90)
    at com.google.dart.compiler.resolver.Resolver$ResolveElementsVisitor.visitClass(Resolver.java:236)
    at com.google.dart.compiler.resolver.Resolver$ResolveElementsVisitor.visitClass(Resolver.java:1)
    at com.google.dart.compiler.ast.DartClass.accept(DartClass.java:175)
    at com.google.dart.compiler.resolver.Resolver$ResolveElementsVisitor.visitUnit(Resolver.java:200)
    at com.google.dart.compiler.resolver.Resolver$ResolveElementsVisitor.visitUnit(Resolver.java:1)
    at com.google.dart.compiler.ast.DartUnit.accept(DartUnit.java:107)
    at com.google.dart.compiler.resolver.Resolver.exec(Resolver.java:112)
    at com.google.dart.compiler.DeltaAnalyzer.analyze(DeltaAnalyzer.java:72)
    at com.google.dart.compiler.DartCompiler.analyzeDelta(DartCompiler.java:1209)
    at com.google.dart.tools.core.utilities.compiler.DartCompilerUtilities$DeltaAnalysisRunnable.run(DartCompilerUtilities.java:266)
    at com.google.dart.tools.core.utilities.compiler.DartCompilerUtilities$CompilerRunner.runSafe(DartCompilerUtilities.java:92)
    at com.google.dart.tools.core.utilities.compiler.DartCompilerUtilities.analyzeDelta(DartCompilerUtilities.java:465)
    at com.google.dart.tools.core.internal.completion.CompletionEngine.complete(CompletionEngine.java:1066)
    at com.google.dart.tools.core.internal.completion.CompletionEngine.complete(CompletionEngine.java:996)
    at com.google.dart.tools.core.internal.model.OpenableElementImpl.codeComplete(OpenableElementImpl.java:374)
    at com.google.dart.tools.core.internal.model.CompilationUnitImpl.codeComplete(CompilationUnitImpl.java:899)
    at com.google.dart.tools.core.internal.model.CompilationUnitImpl.codeComplete(CompilationUnitImpl.java:892)
    at com.google.dart.tools.core.internal.model.CompilationUnitImpl.codeComplete(CompilationUnitImpl.java:880)
    at com.google.dart.tools.ui.internal.text.dart.DartCompletionProposalComputer.internalComputeCompletionProposals(DartCompletionProposalComputer.java:251)
    at com.google.dart.tools.ui.internal.text.dart.DartCompletionProposalComputer.computeCompletionProposals(DartCompletionProposalComputer.java:122)
    at com.google.dart.tools.ui.internal.text.dart.CompletionProposalComputerDescriptor.computeCompletionProposals(CompletionProposalComputerDescriptor.java:224)
    at com.google.dart.tools.ui.internal.text.dart.CompletionProposalCategory.computeCompletionProposals(CompletionProposalCategory.java:119)
    at com.google.dart.tools.ui.internal.text.dart.ContentAssistProcessor.collectProposals(ContentAssistProcessor.java:407)
    at com.google.dart.tools.ui.internal.text.dart.ContentAssistProcessor.computeCompletionProposals(ContentAssistProcessor.java:227)
    at org.eclipse.jface.text.contentassist.ContentAssistant.computeCompletionProposals(ContentAssistant.java:1830)
    at org.eclipse.jface.text.contentassist.CompletionProposalPopup.computeProposals(CompletionProposalPopup.java:556)
    at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$16(CompletionProposalPopup.java:553)
    at org.eclipse.jface.text.contentassist.CompletionProposalPopup$2.run(CompletionProposalPopup.java:488)
    at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
    at org.eclipse.jface.text.contentassist.CompletionProposalPopup.showProposals(CompletionProposalPopup.java:482)
    at org.eclipse.jface.text.contentassist.ContentAssistant.showPossibleCompletions(ContentAssistant.java:1656)
    at com.google.dart.tools.ui.internal.text.editor.CompilationUnitEditor$AdaptedSourceViewer.doOperation(CompilationUnitEditor.java:172)
    at org.eclipse.ui.texteditor.ContentAssistAction$1.run(ContentAssistAction.java:82)
    at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
    at org.eclipse.ui.texteditor.ContentAssistAction.run(ContentAssistAction.java:80)
    at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
    at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:185)
    at org.eclipse.ui.internal.handlers.LegacyHandlerWrapper.execute(LegacyHandlerWrapper.java:109)
    at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
    at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
    at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
    at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:468)
    at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:786)
    at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:885)
    at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:567)
    at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:508)
    at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboard.java:123)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1069)
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4124)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1457)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1480)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1465)
    at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1494)
    at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1490)
    at org.eclipse.swt.widgets.Canvas.sendKeyEvent(Canvas.java:463)
    at org.eclipse.swt.widgets.Control.doCommandBySelector(Control.java:1051)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:5560)
    at org.eclipse.swt.internal.cocoa.OS.objc_msgSend(Native Method)
    at org.eclipse.swt.internal.cocoa.NSResponder.interpretKeyEvents(NSResponder.java:68)
    at org.eclipse.swt.widgets.Composite.keyDown(Composite.java:587)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:5470)
    at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
    at org.eclipse.swt.widgets.Widget.callSuper(Widget.java:220)
    at org.eclipse.swt.widgets.Widget.windowSendEvent(Widget.java:2092)
    at org.eclipse.swt.widgets.Shell.windowSendEvent(Shell.java:2255)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:5532)
    at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
    at org.eclipse.swt.widgets.Display.applicationSendEvent(Display.java:4986)
    at org.eclipse.swt.widgets.Display.applicationProc(Display.java:5135)
    at org.eclipse.swt.internal.cocoa.OS.objc_msgSend(Native Method)
    at org.eclipse.swt.internal.cocoa.NSApplication.sendEvent(NSApplication.java:128)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3607)
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494)
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)

@DartBot
Copy link

DartBot commented Nov 17, 2011

This comment was originally written by zundel@google.com


Can you retest in the editor after syncing past r1625? I've updated getMostSpecificType() in the compile-time constant analysis to never throw an ICE.


Set owner to zundel@google.com.

@DartBot
Copy link

DartBot commented Nov 28, 2011

This comment was originally written by zundel@google.com


for retest


Set owner to @stevemessick.

@stevemessick
Copy link
Contributor Author

Added Fixed label.

@stevemessick stevemessick self-assigned this Jan 23, 2012
copybara-service bot pushed a commit that referenced this issue Jun 2, 2022
Changes:
```
> git log --format="%C(auto) %h %s" 5699caf..e3f4bd2
 https://dart.googlesource.com/markdown.git/+/e3f4bd2 example: update CDN asset links (#435)
 https://dart.googlesource.com/markdown.git/+/a678bfc example: add GitHub markdown CSS (#434)
 https://dart.googlesource.com/markdown.git/+/bc79c43 Merge pull request #425 from dart-lang/pq-patch-1
 https://dart.googlesource.com/markdown.git/+/4e8aa03 add pub badge
 https://dart.googlesource.com/markdown.git/+/7987e1e Remove dependency on third party package:charcode.
 https://dart.googlesource.com/markdown.git/+/90995fd Split block_parser.dart and inline_parser.dart (#422)
 https://dart.googlesource.com/markdown.git/+/8bb9062 Add trailing commas to some parameter lists to get better formatting (#420)
 https://dart.googlesource.com/markdown.git/+/1c5f2e7 Enable raw strings lint rules (#418)
 https://dart.googlesource.com/markdown.git/+/4784153 Enable use_if_null_to_convert_nulls_to_bools lint rule (#417)
 https://dart.googlesource.com/markdown.git/+/0d67e99 Enable prefer_interpolation_to_compose_strings (#416)
 https://dart.googlesource.com/markdown.git/+/5561351 Enable prefer_final_locals lint rule (#415)
 https://dart.googlesource.com/markdown.git/+/6d39147 Create DelimiterSyntax to replace TagSyntax (#407)
 https://dart.googlesource.com/markdown.git/+/4f4e899 Add caseSensitive parameter on the InlineSyntax constructor (#400)
 https://dart.googlesource.com/markdown.git/+/e16aff0 Check parser.isDone when title is null in _parseInlineBracketedLink (#394)
 https://dart.googlesource.com/markdown.git/+/3471578 Use `Uri.toFilePath()` instead of `Uri.path` for locating tests (#396)

```

Diff: https://dart.googlesource.com/markdown.git/+/5699cafa9ef004875fd7de8ae9ea00e5295e87a4~..e3f4bd28c9e61b522f75f291d4d6cfcfeccd83ee/
Change-Id: Ie04b17dfcce57fcd9e814bd8b9a09677a91136d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246984
Auto-Submit: Devon Carew <devoncarew@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
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