mirror of
https://github.com/fluencelabs/aqua.git
synced 2024-12-04 06:30:17 +00:00
fix(compiler): Passing closures with abilities [LNG-314] (#1035)
This commit is contained in:
parent
d5cd77bb86
commit
5241f522d8
2
.github/workflows/sbt-tests.yml
vendored
2
.github/workflows/sbt-tests.yml
vendored
@ -29,4 +29,4 @@ jobs:
|
||||
apps: sbt
|
||||
|
||||
- name: Run tests
|
||||
run: sbt test
|
||||
run: env JAVA_OPTS="-Xmx4G" sbt test
|
||||
|
@ -1,3 +1,23 @@
|
||||
func arr() -> string:
|
||||
n = "str"
|
||||
<- n
|
||||
aqua M
|
||||
|
||||
export bugLng314
|
||||
|
||||
ability WorkerJob:
|
||||
runOnSingleWorker(w: string) -> string
|
||||
|
||||
func disjoint_run{WorkerJob}() -> -> string:
|
||||
run = func () -> string:
|
||||
r <- WorkerJob.runOnSingleWorker()
|
||||
<- r
|
||||
<- run
|
||||
|
||||
func runJob(j: -> string) -> string:
|
||||
<- j()
|
||||
|
||||
func bugLng314() -> string:
|
||||
job2 = () -> string:
|
||||
<- "strstrstr"
|
||||
worker_job = WorkerJob(runOnSingleWorker = job2)
|
||||
subnet_job <- disjoint_run{worker_job}()
|
||||
res <- runJob(subnet_job)
|
||||
<- res
|
23
integration-tests/aqua/examples/abilitiesClosure.aqua
Normal file
23
integration-tests/aqua/examples/abilitiesClosure.aqua
Normal file
@ -0,0 +1,23 @@
|
||||
aqua M
|
||||
|
||||
export bugLNG314
|
||||
|
||||
ability WorkerJob:
|
||||
runOnSingleWorker(w: string) -> string
|
||||
|
||||
func disjoint_run{WorkerJob}() -> -> string:
|
||||
run = func () -> string:
|
||||
r <- WorkerJob.runOnSingleWorker()
|
||||
<- r
|
||||
<- run
|
||||
|
||||
func runJob(j: -> string) -> string:
|
||||
<- j()
|
||||
|
||||
func bugLNG314() -> string:
|
||||
job2 = () -> string:
|
||||
<- "strstrstr"
|
||||
worker_job = WorkerJob(runOnSingleWorker = job2)
|
||||
subnet_job <- disjoint_run{worker_job}()
|
||||
res <- runJob(subnet_job)
|
||||
<- res
|
@ -40,6 +40,9 @@ import {
|
||||
multipleAbilityWithClosureCall,
|
||||
returnSrvAsAbilityCall,
|
||||
} from "../examples/abilityCall.js";
|
||||
import {
|
||||
bugLNG314Call,
|
||||
} from "../examples/abilityClosureCall.js";
|
||||
import {
|
||||
nilLengthCall,
|
||||
nilLiteralCall,
|
||||
@ -666,6 +669,11 @@ describe("Testing examples", () => {
|
||||
expect(result).toStrictEqual(["default-id", "resolved-id"]);
|
||||
});
|
||||
|
||||
it("abilitiesClosure.aqua bug LNG-314", async () => {
|
||||
let result = await bugLNG314Call();
|
||||
expect(result).toEqual("strstrstr");
|
||||
});
|
||||
|
||||
it("functors.aqua LNG-119 bug", async () => {
|
||||
let result = await bugLng119Call();
|
||||
expect(result).toEqual([1]);
|
||||
|
7
integration-tests/src/examples/abilityClosureCall.ts
Normal file
7
integration-tests/src/examples/abilityClosureCall.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import {
|
||||
bugLNG314
|
||||
} from "../compiled/examples/abilitiesClosure.js";
|
||||
|
||||
export async function bugLNG314Call(): Promise<string> {
|
||||
return await bugLNG314();
|
||||
}
|
@ -497,7 +497,7 @@ object ArrowInliner extends Logging {
|
||||
exports <- Exports[S].exports
|
||||
streams <- getOutsideStreamNames
|
||||
arrows = passArrows ++ arrowsFromAbilities
|
||||
|
||||
|
||||
inlineResult <- Exports[S].scope(
|
||||
Arrows[S].scope(
|
||||
for {
|
||||
|
@ -37,6 +37,7 @@ object MakeAbilityRawInliner extends RawInliner[AbilityRaw] {
|
||||
varModel = VarModel(name, raw.baseType)
|
||||
valsInline = foldedFields.toList.foldMap { case (_, inline) => inline }.desugar
|
||||
_ <- updateFields(name, foldedFields)
|
||||
_ <- Exports[S].resolved(name, varModel)
|
||||
} yield {
|
||||
(
|
||||
varModel,
|
||||
|
@ -35,7 +35,7 @@ trait Arrows[S] extends Scoped[S] {
|
||||
for {
|
||||
arrs <- arrows
|
||||
capturedVars <- Exports[S].gather(arrow.capturedVars.toSeq)
|
||||
capturedArrows = arrs.filterKeys(arrow.capturedVars).toMap ++
|
||||
capturedArrows = arrs.view.filterKeys(arrow.capturedVars).toMap ++
|
||||
Arrows.arrowsByValues(arrs, capturedVars)
|
||||
funcArrow = FuncArrow.fromRaw(arrow, capturedArrows, capturedVars, topology)
|
||||
_ <- save(arrow.name, funcArrow)
|
||||
|
@ -150,7 +150,7 @@ object Exports {
|
||||
(fieldName, _) = field
|
||||
} yield AbilityType.fullName(variable, fieldName)
|
||||
|
||||
state.filterKeys(names.toSet ++ related).toMap
|
||||
state.view.filterKeys(names.toSet ++ related).toMap
|
||||
}
|
||||
|
||||
// Get last linked VarModel
|
||||
|
Loading…
Reference in New Issue
Block a user