Skip to content

Commit

Permalink
fix annotation of captures
Browse files Browse the repository at this point in the history
- we have to at least also run AnnotateCaptures in addition to the frontend
- we have to reset allCaptures in AnnotateCaptures so old information does not persist over multiple passes
- we must not cache the parser, otherwise old capture information is used
  • Loading branch information
dvdvgt committed Nov 13, 2023
1 parent 11218d9 commit 18ca742
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion effekt/jvm/src/main/scala/effekt/Driver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ trait Driver extends kiama.util.Compiler[EffektConfig, EffektError] { outer =>
}

// we are in one of three exclusive modes: LSPServer, Compile, Run
if (config.server()) { compiler.runFrontend(src) }
if (config.server()) { compiler.runMiddleend(src) }
else if (config.interpret()) { compile() foreach runner.eval }
else if (config.build()) { compile() foreach runner.build }
else if (config.compile()) { compile() }
Expand Down
8 changes: 8 additions & 0 deletions effekt/shared/src/main/scala/effekt/Compiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ trait Compiler[Executable] {
mod
}

def runMiddleend(source: Source)(using Context): Option[Typechecked] =
(Parser andThen
Namer andThen
BoxUnboxInference andThen
Typer andThen
Wellformedness andThen
AnnotateCaptures)(source)

/**
* Called after running the frontend from editor services.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ object AnnotateCaptures extends Phase[Typechecked, Typechecked], Query[Unit, Cap

def annotate(tree: source.ModuleDecl, src: Source)(using Context): Unit =
given Unit = ();
// reset allCaptures since multiple runs of this Phase may pollute it with outdated information
allCaptures = Nil
query(tree)
Context.annotate(Annotations.CaptureForFile, src, allCaptures)

Expand Down

0 comments on commit 18ca742

Please sign in to comment.