Skip to content

Crash when selecting ! on block #5386

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
biboudis opened this issue Nov 4, 2018 · 4 comments
Closed

Crash when selecting ! on block #5386

biboudis opened this issue Nov 4, 2018 · 4 comments

Comments

@biboudis
Copy link
Contributor

biboudis commented Nov 4, 2018

object Test {
  inline def assert(assertion: => Boolean): Boolean = !assertion

  def test = assert({println("Boom");true})
}
java.lang.AssertionError: NoDenotation.owner while compiling tests/run-separate-compilation/gestalt-innerclassmacro-inline/InnerClassMacro_1.scala
Exception in thread "main" java.lang.AssertionError: NoDenotation.owner
	at dotty.tools.dotc.core.SymDenotations$NoDenotation$.owner(SymDenotations.scala:1931)
	at dotty.tools.dotc.transform.Erasure$Typer.mapOwner$1(Erasure.scala:408)
	at dotty.tools.dotc.transform.Erasure$Typer.typedSelect(Erasure.scala:412)
	at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:1863)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1936)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:110)
	at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1968)
	at dotty.tools.dotc.reporting.trace$.apply(trace.scala:40)
@biboudis
Copy link
Contributor Author

biboudis commented Nov 4, 2018

Ok now this doesn't raise the error.

val a = assertion
!a

@biboudis
Copy link
Contributor Author

biboudis commented Nov 4, 2018

New minimization 😮

object Test {
  !{
    println("!")
    true
  }
}

@biboudis biboudis changed the title Crash when selecting ! on block after inlining Crash when selecting ! on block Nov 4, 2018
@odersky
Copy link
Contributor

odersky commented Nov 4, 2018

It's a combination of two things:

  • The expression is constant folded, so its type does not have a symbol.
  • The expression is impure, so it's not reduced to a constant literal.

The problem is that Erasure does not expect to see a Select node with these two properties.

@biboudis
Copy link
Contributor Author

biboudis commented Nov 4, 2018

I see. What do you think about the #5387 fix?

odersky added a commit that referenced this issue Nov 21, 2018
Fix #5386: Normalize unary operator expressions
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

2 participants