Skip to content

compiler throw AssertionError inline val a = ${b} #14679

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
xuwei-k opened this issue Mar 13, 2022 · 1 comment · Fixed by #15072
Closed

compiler throw AssertionError inline val a = ${b} #14679

xuwei-k opened this issue Mar 13, 2022 · 1 comment · Fixed by #15072
Assignees
Labels
Milestone

Comments

@xuwei-k
Copy link
Contributor

xuwei-k commented Mar 13, 2022

Compiler version

  • 3.1.1
  • 3.1.2-RC2
  • 3.2.0-RC1-bin-20220308-29073f1-NIGHTLY

Minimized code

I think this is invalid code. compiler should be report compile error instead of AssertionError.

import scala.quoted.Quotes
import scala.quoted.Expr

object A {
  inline val a = ${b}

  def b(using Quotes): Expr[Unit] = '{ () }
}

Output (click arrow to expand)

[error] java.lang.AssertionError: assertion failed
[error] scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:11)
[error] dotty.tools.dotc.typer.QuotesAndSplices.markAsMacro$1(QuotesAndSplices.scala:107)
[error] dotty.tools.dotc.typer.QuotesAndSplices.typedSplice(QuotesAndSplices.scala:108)
[error] dotty.tools.dotc.typer.QuotesAndSplices.typedSplice$(QuotesAndSplices.scala:35)
[error] dotty.tools.dotc.typer.Typer.typedSplice(Typer.scala:119)
[error] dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2853)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2872)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2937)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2941)
[error] dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3057)
[error] dotty.tools.dotc.typer.Namer.typedAheadExpr$$anonfun$1(Namer.scala:1473)
[error] dotty.tools.dotc.typer.Namer.typedAhead(Namer.scala:1463)
[error] dotty.tools.dotc.typer.Namer.typedAheadExpr(Namer.scala:1473)
[error] dotty.tools.dotc.typer.Namer.typedAheadRhs$1$$anonfun$1(Namer.scala:1710)
[error] dotty.tools.dotc.typer.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:238)
[error] dotty.tools.dotc.typer.Namer.typedAheadRhs$1(Namer.scala:1710)
[error] dotty.tools.dotc.typer.Namer.rhsType$1(Namer.scala:1718)
[error] dotty.tools.dotc.typer.Namer.cookedRhsType$1(Namer.scala:1736)
[error] dotty.tools.dotc.typer.Namer.lhsType$1(Namer.scala:1737)
[error] dotty.tools.dotc.typer.Namer.inferredResultType(Namer.scala:1748)
[error] dotty.tools.dotc.typer.Namer.inferredType$1(Namer.scala:1512)
[error] dotty.tools.dotc.typer.Namer.valOrDefDefSig(Namer.scala:1519)
[error] dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:778)
[error] dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:914)
[error] dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:806)
[error] dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:168)
[error] dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:188)
[error] dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:190)
[error] dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:370)
[error] dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:2751)
[error] dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2776)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2871)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2937)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2941)
[error] dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2963)
[error] dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3013)
[error] dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2454)
[error] dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:2797)
[error] dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2801)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2871)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2937)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2941)
[error] dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2963)
[error] dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3013)
[error] dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2581)
[error] dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2842)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2872)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2937)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:2941)
[error] dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3057)
[error] dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$1(TyperPhase.scala:47)
[error] dotty.tools.dotc.core.Phases$Phase.monitor(Phases.scala:411)
[error] dotty.tools.dotc.typer.TyperPhase.typeCheck(TyperPhase.scala:54)
[error] dotty.tools.dotc.typer.TyperPhase.runOn$$anonfun$3(TyperPhase.scala:88)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.immutable.List.foreach(List.scala:333)
[error] dotty.tools.dotc.typer.TyperPhase.runOn(TyperPhase.scala:88)
[error] dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:259)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1328)
[error] dotty.tools.dotc.Run.runPhases$1(Run.scala:270)
[error] dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:278)
[error] scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
[error] dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:68)
[error] dotty.tools.dotc.Run.compileUnits(Run.scala:287)
[error] dotty.tools.dotc.Run.compileSources(Run.scala:220)
[error] dotty.tools.dotc.Run.compile(Run.scala:204)
[error] dotty.tools.dotc.Driver.doCompile(Driver.scala:39)
[error] dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:88)
[error] dotty.tools.xsbt.CompilerBridge.run(CompilerBridge.java:22)
[error] sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$7(MixedAnalyzingCompiler.scala:192)
[error] scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error] sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:247)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:182)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4$adapted(MixedAnalyzingCompiler.scala:163)
[error] sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:239)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:163)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:210)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:528)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:528)
[error] sbt.internal.inc.Incremental$.$anonfun$apply$5(Incremental.scala:177)
[error] sbt.internal.inc.Incremental$.$anonfun$apply$5$adapted(Incremental.scala:175)
[error] sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:461)
[error] sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:116)
[error] sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:56)
[error] sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:52)
[error] sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:263)
[error] sbt.internal.inc.Incremental$.$anonfun$incrementalCompile$8(Incremental.scala:416)
[error] sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:503)
[error] sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:403)
[error] sbt.internal.inc.Incremental$.apply(Incremental.scala:169)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:528)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:482)
[error] sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:420)
[error] sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137)
[error] sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:2366)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$2(Defaults.scala:2316)
[error] sbt.internal.server.BspCompileTask$.$anonfun$compute$1(BspCompileTask.scala:30)
[error] sbt.internal.io.Retry$.apply(Retry.scala:46)
[error] sbt.internal.io.Retry$.apply(Retry.scala:28)
[error] sbt.internal.io.Retry$.apply(Retry.scala:23)
[error] sbt.internal.server.BspCompileTask$.compute(BspCompileTask.scala:30)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:2314)
[error] scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
[error] sbt.std.Transform$$anon$4.work(Transform.scala:68)
[error] sbt.Execute.$anonfun$submit$2(Execute.scala:282)
[error] sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
[error] sbt.Execute.work(Execute.scala:291)
[error] sbt.Execute.$anonfun$submit$1(Execute.scala:282)
[error] sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error] sbt.CompletionService$$anon$2.call(CompletionService.scala:64)
[error] java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[error] java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error] java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error] java.lang.Thread.run(Thread.java:750)
@xuwei-k xuwei-k added itype:bug itype:crash stat:needs triage Every issue needs to have an "area" and "itype" label labels Mar 13, 2022
@nicolasstucki nicolasstucki added area:metaprogramming:quotes Issues related to quotes and splices and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Mar 14, 2022
@nicolasstucki nicolasstucki self-assigned this Mar 14, 2022
@nicolasstucki
Copy link
Contributor

Should show an error. Splices are not allowed in inline vals.

nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Apr 29, 2022
This fixes a false positive where we mistakenly interpreted an
`inline val` as an inline method.

Fixes scala#14679
bishabosha pushed a commit to dotty-staging/dotty that referenced this issue Oct 18, 2022
This fixes a false positive where we mistakenly interpreted an
`inline val` as an inline method.

Fixes scala#14679
@Kordyjan Kordyjan added this to the 3.2.0 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants