Skip to content
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

Also export and import captures to allow referring to them in other modules #382

Merged
merged 1 commit into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions effekt/shared/src/main/scala/effekt/Namer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ object Namer extends Phase[Parsed, NameResolved] {

def processDependency(path: String) =
val modImport = Context.moduleOf(path)
scope.defineAll(modImport.terms, modImport.types, Map.empty)
scope.defineAll(modImport.terms, modImport.types, modImport.captures)
modImport

// process the prelude (but don't if we are processing the prelude already)
Expand All @@ -70,7 +70,7 @@ object Namer extends Phase[Parsed, NameResolved] {

// We only want to import each dependency once.
val allImports = (processedPreludes ++ imports).distinct
Context.module.exports(allImports, scope.terms.toMap, scope.types.toMap)
Context.module.exports(allImports, scope.terms.toMap, scope.types.toMap, scope.captures.toMap)
decl
}

Expand Down
8 changes: 7 additions & 1 deletion effekt/shared/src/main/scala/effekt/symbols/symbols.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ case class Module(
private var _types: Map[String, TypeSymbol] = _
def types = _types

private var _captures: Map[String, Capture] = _
def captures = _captures


private var _imports: List[Module] = _
def imports = _imports

Expand All @@ -70,11 +74,13 @@ case class Module(
def exports(
imports: List[Module],
terms: Map[String, Set[TermSymbol]],
types: Map[String, TypeSymbol]
types: Map[String, TypeSymbol],
captures: Map[String, Capture],
): this.type = {
_imports = imports
_terms = terms
_types = types
_captures = captures
this
}
}
Expand Down
1 change: 1 addition & 0 deletions examples/pos/imports/issue270.check
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
worked
7 changes: 7 additions & 0 deletions examples/pos/imports/issue270.effekt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module examples/pos/imports/importing_resources

import examples/pos/imports/resources

extern { r } def doNothing(): Unit = ""

def main() = println("worked")
Empty file.
6 changes: 6 additions & 0 deletions examples/pos/imports/resources.effekt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module examples/pos/imports/resources

extern interface R
extern resource r: R

def main() = ()
Loading