Skip to content

os-lib 0.11.4 fails at runtime with expecty #361

@Gedochao

Description

@Gedochao

Version

0.11.4

Reproduction

With Scala CLI:

//> using dep com.eed3si9n.expecty::expecty:0.17.0
//> using dep com.lihaoyi::os-lib:0.11.4
import com.eed3si9n.expecty.Expecty.expect
def findCodeBlocks(subPath: os.SubPath): Boolean = true
@main def repro() = expect(findCodeBlocks(os.sub / "Example.md"))

Compiling results in a RuntimeException:

[error] ./repro.scala:5:21
[error] Exception occurred while executing macro expansion.
[error] java.lang.RuntimeException: Expecty: Error rewriting expression.
[error] Text:                            findCodeBlocks(os.sub / "Example.md")
[error] AST : Apply(Ident("findCodeBlocks"), List(Apply(Select(Select(Select(Ident("os"), "package"), "sub"), "/"), List(Typed(Apply(Select(New(TypeIdent("RelPathChunk")), "<init>"), List(Apply(Ident("fromStringSegments"), List(Apply(Apply(TypeApply(Select(Ident("Array"), "apply"), List(Inferred())), List(Typed(Repeated(List(Literal(StringConstant("Example.md"))), Inferred()), Inferred()))), List(Apply(TypeApply(Select(Ident("ClassTag"), "apply"), List(Inferred())), List(Literal(ClassOfConstant(TypeRef(ThisType(TypeRef(NoPrefix(), "lang")), "String"))))))))))), TypeIdent("PathChunk"))))))
[error]         at com.eed3si9n.expecty.RecorderMacro.recordExpressions(RecorderMacro.scala:103)
[error]         at com.eed3si9n.expecty.RecorderMacro.apply$$anonfun$1$$anonfun$1$$anonfun$1(RecorderMacro.scala:36)
[error]         at scala.collection.immutable.List.flatMap(List.scala:294)
[error]         at com.eed3si9n.expecty.RecorderMacro.apply$$anonfun$1$$anonfun$1(RecorderMacro.scala:36)
[error]         at com.eed3si9n.expecty.RecorderMacro.apply$$anonfun$1(RecorderMacro.scala:32)
[error]         at com.eed3si9n.expecty.RecorderMacro.apply$$anonfun$adapted$1(RecorderMacro.scala:38)
[error]         at dotty.tools.dotc.quoted.PickledQuotes$$anon$1.transform(PickledQuotes.scala:111)
[error]         at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1571)
[error]         at dotty.tools.dotc.quoted.PickledQuotes$$anon$1.transform(PickledQuotes.scala:136)
[error]         at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformBlock$$anonfun$1$$anonfun$1(tpd.scala:1298)
[error]         at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.loop$2(tpd.scala:1280)
[error]         at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformStats(tpd.scala:1293)
[error]         at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformBlock(tpd.scala:1298)
[error]         at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1551)
[error]         at dotty.tools.dotc.quoted.PickledQuotes$$anon$1.transform(PickledQuotes.scala:136)
[error]         at dotty.tools.dotc.quoted.PickledQuotes$.spliceTerms(PickledQuotes.scala:153)
[error]         at dotty.tools.dotc.quoted.PickledQuotes$.unpickleTerm(PickledQuotes.scala:89)
[error]         at scala.quoted.runtime.impl.QuotesImpl.unpickleExprV2(QuotesImpl.scala:3299)
[error]         at com.eed3si9n.expecty.RecorderMacro.apply(RecorderMacro.scala:38)
[error]         at com.eed3si9n.expecty.RecorderMacro$.varargs(RecorderMacro.scala:259)
[error] Caused by: java.util.NoSuchElementException: None.get
[error]         at scala.None$.get(Option.scala:627)
[error]         at scala.None$.get(Option.scala:626)
[error]         at com.eed3si9n.expecty.RecorderMacro.getAnchor(RecorderMacro.scala:238)
[error]         at com.eed3si9n.expecty.RecorderMacro.getAnchor(RecorderMacro.scala:236)
[error]         at com.eed3si9n.expecty.RecorderMacro.getAnchor(RecorderMacro.scala:235)
[error]         at com.eed3si9n.expecty.RecorderMacro.recordValue(RecorderMacro.scala:220)
[error]         at com.eed3si9n.expecty.RecorderMacro.recordAllValues(RecorderMacro.scala:133)
[error]         at com.eed3si9n.expecty.RecorderMacro.recordSubValues$$anonfun$4(RecorderMacro.scala:163)
[error]         at scala.collection.immutable.List.map(List.scala:247)
[error]         at com.eed3si9n.expecty.RecorderMacro.recordSubValues(RecorderMacro.scala:163)
[error]         at com.eed3si9n.expecty.RecorderMacro.recordAllValues(RecorderMacro.scala:133)
[error]         at com.eed3si9n.expecty.RecorderMacro.recordSubValues$$anonfun$4(RecorderMacro.scala:163)
[error]         at scala.collection.immutable.List.map(List.scala:247)
[error]         at com.eed3si9n.expecty.RecorderMacro.recordSubValues(RecorderMacro.scala:163)
[error]         at com.eed3si9n.expecty.RecorderMacro.recordAllValues(RecorderMacro.scala:133)
[error]         at com.eed3si9n.expecty.RecorderMacro.recordSubValues$$anonfun$4(RecorderMacro.scala:163)
[error]         at scala.collection.immutable.List.map(List.scala:247)
[error]         at com.eed3si9n.expecty.RecorderMacro.recordSubValues(RecorderMacro.scala:163)
[error]         at com.eed3si9n.expecty.RecorderMacro.recordSubValues(RecorderMacro.scala:173)
[error]         at com.eed3si9n.expecty.RecorderMacro.recordAllValues(RecorderMacro.scala:133)
[error]         at com.eed3si9n.expecty.RecorderMacro.recordSubValues$$anonfun$4(RecorderMacro.scala:163)
[error]         at scala.collection.immutable.List.map(List.scala:247)
[error]         at com.eed3si9n.expecty.RecorderMacro.recordSubValues(RecorderMacro.scala:163)
[error]         at com.eed3si9n.expecty.RecorderMacro.recordAllValues(RecorderMacro.scala:133)
[error]         at com.eed3si9n.expecty.RecorderMacro.recordSubValues$$anonfun$4(RecorderMacro.scala:163)
[error]         at scala.collection.immutable.List.map(List.scala:247)
[error]         at com.eed3si9n.expecty.RecorderMacro.recordSubValues(RecorderMacro.scala:163)
[error]         at com.eed3si9n.expecty.RecorderMacro.recordAllValues(RecorderMacro.scala:133)
[error]         at com.eed3si9n.expecty.RecorderMacro.recordExpression(RecorderMacro.scala:109)
[error]         at com.eed3si9n.expecty.RecorderMacro.recordExpressions(RecorderMacro.scala:99)
[error]         at com.eed3si9n.expecty.RecorderMacro.apply$$anonfun$1$$anonfun$1$$anonfun$1(RecorderMacro.scala:36)
[error]         at scala.collection.immutable.List.flatMap(List.scala:294)
[error]         at com.eed3si9n.expecty.RecorderMacro.apply$$anonfun$1$$anonfun$1(RecorderMacro.scala:36)
[error]         at com.eed3si9n.expecty.RecorderMacro.apply$$anonfun$1(RecorderMacro.scala:32)
[error]         at com.eed3si9n.expecty.RecorderMacro.apply$$anonfun$adapted$1(RecorderMacro.scala:38)
[error]         at dotty.tools.dotc.quoted.PickledQuotes$$anon$1.transform(PickledQuotes.scala:111)
[error]         at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1571)
[error]         at dotty.tools.dotc.quoted.PickledQuotes$$anon$1.transform(PickledQuotes.scala:136)
[error]         at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformBlock$$anonfun$1$$anonfun$1(tpd.scala:1298)
[error]         at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.loop$2(tpd.scala:1280)
[error]         at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformStats(tpd.scala:1293)
[error]         at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformBlock(tpd.scala:1298)
[error]         at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1551)
[error]         at dotty.tools.dotc.quoted.PickledQuotes$$anon$1.transform(PickledQuotes.scala:136)
[error]         at dotty.tools.dotc.quoted.PickledQuotes$.spliceTerms(PickledQuotes.scala:153)
[error]         at dotty.tools.dotc.quoted.PickledQuotes$.unpickleTerm(PickledQuotes.scala:89)
[error]         at scala.quoted.runtime.impl.QuotesImpl.unpickleExprV2(QuotesImpl.scala:3299)
[error]         at com.eed3si9n.expecty.RecorderMacro.apply(RecorderMacro.scala:38)
[error]         at com.eed3si9n.expecty.RecorderMacro$.varargs(RecorderMacro.scala:259)
[error]         at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
[error]         at java.base/java.lang.reflect.Method.invoke(Method.java:580)
[error]         at dotty.tools.dotc.quoted.Interpreter.interpretedStaticMethodCall$$anonfun$1(Interpreter.scala:174)
[error]         at dotty.tools.dotc.quoted.Interpreter.stopIfRuntimeException(Interpreter.scala:231)
[error]         at dotty.tools.dotc.quoted.Interpreter.interpretedStaticMethodCall(Interpreter.scala:174)
[error]         at dotty.tools.dotc.quoted.Interpreter.interpretTree(Interpreter.scala:80)
[error]         at dotty.tools.dotc.transform.Splicer$SpliceInterpreter.interpretTree(Splicer.scala:267)
[error]         at dotty.tools.dotc.quoted.Interpreter.interpretTree$$anonfun$2(Interpreter.scala:99)
[error]         at dotty.tools.dotc.transform.Splicer$.$anonfun$2(Splicer.scala:62)
[error]         at scala.Option.fold(Option.scala:263)
[error]         at dotty.tools.dotc.transform.Splicer$.splice(Splicer.scala:62)
[error]         at dotty.tools.dotc.inlines.Inliner.dotty$tools$dotc$inlines$Inliner$$expandMacro(Inliner.scala:1117)
[error]         at dotty.tools.dotc.inlines.Inliner$InlineTyper.typedSplice(Inliner.scala:864)
[error]         at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3569)
[error]         at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3608)
[error]         at dotty.tools.dotc.inlines.Inliner$InlineTyper.typedUnadapted(Inliner.scala:969)
[error]         at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3685)
[error]         at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3690)
[error]         at dotty.tools.dotc.typer.ReTyper.typedTyped(ReTyper.scala:65)
[error]         at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3528)
[error]         at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3608)
[error]         at dotty.tools.dotc.inlines.Inliner$InlineTyper.typedUnadapted(Inliner.scala:969)
[error]         at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3685)
[error]         at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3682)
[error]         at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3690)
[error]         at dotty.tools.dotc.inlines.Inliner.inlined(Inliner.scala:699)
[error]         at dotty.tools.dotc.inlines.Inlines$InlineCall.expand(Inlines.scala:560)
[error]         at dotty.tools.dotc.inlines.Inlines$.inlineCall(Inlines.scala:167)
[error]         at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:94)
[error]         at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:50)
[error]         at dotty.tools.dotc.ast.TreeMapWithTrackedStats.transform(TreeMapWithTrackedStats.scala:63)
[error]         at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transformMemberDef(Inlining.scala:135)
[error]         at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:71)
[error]         at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.loop$2(tpd.scala:1293)
[error]         at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformStats(tpd.scala:1293)
[error]         at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformStats(tpd.scala:1295)
[error]         at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:58)
[error]         at dotty.tools.dotc.ast.TreeMapWithTrackedStats.transform(TreeMapWithTrackedStats.scala:63)
[error]         at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:95)
[error]         at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1605)
[error]         at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67)
[error]         at dotty.tools.dotc.ast.TreeMapWithTrackedStats.transform(TreeMapWithTrackedStats.scala:60)
[error]         at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transformMemberDef(Inlining.scala:135)
[error]         at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:71)
[error]         at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.loop$2(tpd.scala:1293)
[error]         at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformStats(tpd.scala:1293)
[error]         at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformStats(tpd.scala:1295)
[error]         at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1616)
[error]         at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:67)
[error]         at dotty.tools.dotc.ast.TreeMapWithTrackedStats.transform(TreeMapWithTrackedStats.scala:48)
[error]         at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:75)
[error]         at dotty.tools.dotc.transform.Inlining$$anon$2.transform(Inlining.scala:57)
[error]         at dotty.tools.dotc.transform.MacroTransform.run(MacroTransform.scala:20)
[error]         at dotty.tools.dotc.transform.Inlining.run(Inlining.scala:39)
[error]         at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:383)
[error]         at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error]         at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error]         at scala.collection.immutable.List.foreach(List.scala:334)
[error]         at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:376)
[error]         at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:343)
[error]         at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error]         at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error]         at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
[error]         at dotty.tools.dotc.Run.runPhases$1(Run.scala:336)
[error]         at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:383)
[error]         at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:395)
[error]         at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:69)
[error]         at dotty.tools.dotc.Run.compileUnits(Run.scala:395)
[error]         at dotty.tools.dotc.Run.compileSources(Run.scala:282)
[error]         at dotty.tools.dotc.Run.compile(Run.scala:267)
[error]         at dotty.tools.dotc.Driver.doCompile(Driver.scala:37)
[error]         at dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:141)
[error]         at dotty.tools.xsbt.CompilerBridge.run(CompilerBridge.java:22)
[error]         at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91)
[error]         at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.compileSources$1(BloopHighLevelCompiler.scala:148)
[error]         at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.$anonfun$compile$9(BloopHighLevelCompiler.scala:181)
[error]         at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error]         at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.$anonfun$compile$1(BloopHighLevelCompiler.scala:73)
[error]         at bloop.tracing.NoopTracer$.trace(BraveTracer.scala:53)
[error]         at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.timed$1(BloopHighLevelCompiler.scala:72)
[error]         at sbt.internal.inc.bloop.internal.BloopHighLevelCompiler.$anonfun$compile$8(BloopHighLevelCompiler.scala:181)
[error]         at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error]         at monix.eval.internal.TaskRunLoop$.startFull(TaskRunLoop.scala:81)
[error]         at monix.eval.internal.TaskRestartCallback.syncOnSuccess(TaskRestartCallback.scala:101)
[error]         at monix.eval.internal.TaskRestartCallback.onSuccess(TaskRestartCallback.scala:74)
[error]         at monix.eval.internal.TaskExecuteOn$AsyncRegister$$anon$1.run(TaskExecuteOn.scala:71)
[error]         at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.compute(ForkJoinTask.java:1726)
[error]         at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.compute(ForkJoinTask.java:1717)
[error]         at java.base/java.util.concurrent.ForkJoinTask$InterruptibleTask.exec(ForkJoinTask.java:1641)
[error]         at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:507)
[error]         at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1458)
[error]         at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:2034)
[error]         at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:189)
[error] 
[error] @main def repro() = expect(findCodeBlocks(os.sub / "Example.md"))
[error]                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The problem doesn't occur with os-lib 0.11.3

Originally found at: https://github.com/VirtusLab/scala-cli/blob/d2bd538f28994b1bd540f14b5a2e7057ae598411/modules/build/src/test/scala/scala/build/tests/markdown/MarkdownCodeBlockTests.scala#L26
Update PR: VirtusLab/scala-cli#3506

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions