Skip to content

Syntactically invalid code crashes dotty: assertion failed at Types$TypeBounds (Types.scala:3096) #1845

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

Closed
b-studios opened this issue Dec 21, 2016 · 3 comments
Assignees

Comments

@b-studios
Copy link
Contributor

Trying to compile the following syntactically incorrect file, in addition to the expected error messages the compiler crashes.

object Test {
  type X = FooBar.this
}

Stacktrace:

-- Error: examples/bug.scala ---------------------------------------------
3 |}
  |^
  |`.' expected
-- [E025] Syntax Error: examples/bug.scala -------------------------------
2 |  type X = FooBar.this
  |           ^^^^^^^^^^^
  |           identifier expected

longer explanation available when compiling with `-explain`

exception occurred while typechecking examples/bug.scala

exception occurred while compiling examples/bug.scala
Exception in thread "main" java.lang.AssertionError: assertion failed
	at scala.Predef$.assert(Predef.scala:151)
	at dotty.tools.dotc.core.Types$TypeBounds.<init>(Types.scala:3096)
	at dotty.tools.dotc.core.Types$TypeAlias.<init>(Types.scala:3167)
	at dotty.tools.dotc.core.Types$CachedTypeAlias.<init>(Types.scala:3193)
	at dotty.tools.dotc.core.Uniques$TypeAliasUniques.newAlias$1(Uniques.scala:84)
	at dotty.tools.dotc.core.Uniques$TypeAliasUniques.enterIfNew(Uniques.scala:89)
	at dotty.tools.dotc.core.Types$TypeAlias$.apply(Types.scala:3207)
	at dotty.tools.dotc.typer.Namer.typeDefSig(Namer.scala:1114)
	at dotty.tools.dotc.typer.Namer$TypeDefCompleter.typeSig(Namer.scala:699)
	at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:671)
	at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:650)
	...
@felixmulder
Copy link
Contributor

Is this the full code or is there an instance of FooBar floating around somewhere?

Cheers,
Felix

@b-studios
Copy link
Contributor Author

b-studios commented Dec 21, 2016

This is the full code. FooBar is an arbitrary identifier. I stumbled upon this while constructing a test to trigger a ". expected" parse error.

@felixmulder
Copy link
Contributor

Great, thanks for the report!

@odersky odersky self-assigned this Dec 22, 2016
odersky added a commit that referenced this issue Dec 28, 2016
Fix #1845: Survive illegal this-type prefixes
nicolasstucki pushed a commit to dotty-staging/dotty that referenced this issue Jan 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants