Skip to content

CheckInlineConformant is too strict for -Ycheck:frontend #3971

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
gsps opened this issue Feb 7, 2018 · 1 comment
Closed

CheckInlineConformant is too strict for -Ycheck:frontend #3971

gsps opened this issue Feb 7, 2018 · 1 comment

Comments

@gsps
Copy link
Contributor

gsps commented Feb 7, 2018

object BadInlineConstCheck {
  final val MaxSize = Int.MaxValue + 0
}

crashes in checkInlineConformant:

Exception in thread "main" class dotty.tools.dotc.reporting.diagnostic.messages$Error at try/BadInlineConstCheck.scala:2: right-hand side of inline value MaxSize must be a constant expression or a function
	at dotty.tools.dotc.reporting.Reporting.error(Reporter.scala:88)
	at dotty.tools.dotc.reporting.Reporting.error$(Reporter.scala:87)
	at dotty.tools.dotc.core.Contexts$Context.error(Contexts.scala:70)
	at dotty.tools.dotc.typer.Checking.checkInlineConformant(Checking.scala:607)
	at dotty.tools.dotc.typer.Checking.checkInlineConformant$(Checking.scala:600)
	at dotty.tools.dotc.typer.Typer.checkInlineConformant(Typer.scala:82)
	at dotty.tools.dotc.typer.Typer.$anonfun$typedValDef$1(Typer.scala:1352)
(...)

The problem here lies in the isPureExpr check returning false, which seems to be specifically related to the select of Int.MaxValue not being considered pure. Ultimately, refPurity of a reference to the Int module return Idempotent, which makes the overall expression idempotent rather than pure.

The standard settings of -Ycheck don't run into this crash, since they (I think) only check after some simplification on the trees has taken place, replacing the selection by a simple literal of the same constant value.

gsps added a commit to gsps/dotty that referenced this issue Feb 7, 2018
@smarter smarter changed the title CheckInlineConformant is too strict CheckInlineConformant is too strict for -Ycheck:frontend Feb 13, 2018
@smarter
Copy link
Member

smarter commented Feb 13, 2018

Note that this only happens on master when doing -Ycheck:frontend, #725 tracks the remaining test cases that need to be fixed before we turn it on, a few of them are affected by this issue.

smarter added a commit to smarter/dotty that referenced this issue Mar 23, 2018
Necessary for -Ycheck:frontend to work
smarter added a commit to smarter/dotty that referenced this issue Mar 25, 2018
Necessary for -Ycheck:frontend to work
smarter added a commit to dotty-staging/dotty that referenced this issue Apr 9, 2018
Necessary for -Ycheck:frontend to work
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