diff --git a/.github/workflows/sbt-tests.yml b/.github/workflows/sbt-tests.yml index 05712822..e7f3d951 100644 --- a/.github/workflows/sbt-tests.yml +++ b/.github/workflows/sbt-tests.yml @@ -29,4 +29,4 @@ jobs: apps: sbt - name: Run tests - run: sbt test + run: env JAVA_OPTS="-Xmx4G" sbt test diff --git a/aqua-src/antithesis.aqua b/aqua-src/antithesis.aqua index 04fd9406..c18bb1f6 100644 --- a/aqua-src/antithesis.aqua +++ b/aqua-src/antithesis.aqua @@ -1,3 +1,23 @@ -func arr() -> string: - n = "str" - <- n \ No newline at end of file +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 \ No newline at end of file diff --git a/integration-tests/aqua/examples/abilitiesClosure.aqua b/integration-tests/aqua/examples/abilitiesClosure.aqua new file mode 100644 index 00000000..d5b2b165 --- /dev/null +++ b/integration-tests/aqua/examples/abilitiesClosure.aqua @@ -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 \ No newline at end of file diff --git a/integration-tests/src/__test__/examples.spec.ts b/integration-tests/src/__test__/examples.spec.ts index 34b5a63d..8dc2dad2 100644 --- a/integration-tests/src/__test__/examples.spec.ts +++ b/integration-tests/src/__test__/examples.spec.ts @@ -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]); diff --git a/integration-tests/src/examples/abilityClosureCall.ts b/integration-tests/src/examples/abilityClosureCall.ts new file mode 100644 index 00000000..5cbb5c5e --- /dev/null +++ b/integration-tests/src/examples/abilityClosureCall.ts @@ -0,0 +1,7 @@ +import { + bugLNG314 +} from "../compiled/examples/abilitiesClosure.js"; + +export async function bugLNG314Call(): Promise { + return await bugLNG314(); +} diff --git a/model/inline/src/main/scala/aqua/model/inline/ArrowInliner.scala b/model/inline/src/main/scala/aqua/model/inline/ArrowInliner.scala index f69d2644..8288fae6 100644 --- a/model/inline/src/main/scala/aqua/model/inline/ArrowInliner.scala +++ b/model/inline/src/main/scala/aqua/model/inline/ArrowInliner.scala @@ -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 { diff --git a/model/inline/src/main/scala/aqua/model/inline/raw/MakeAbilityRawInliner.scala b/model/inline/src/main/scala/aqua/model/inline/raw/MakeAbilityRawInliner.scala index 0eae5c10..6f9deab0 100644 --- a/model/inline/src/main/scala/aqua/model/inline/raw/MakeAbilityRawInliner.scala +++ b/model/inline/src/main/scala/aqua/model/inline/raw/MakeAbilityRawInliner.scala @@ -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, diff --git a/model/inline/src/main/scala/aqua/model/inline/state/Arrows.scala b/model/inline/src/main/scala/aqua/model/inline/state/Arrows.scala index e6f53efc..34759319 100644 --- a/model/inline/src/main/scala/aqua/model/inline/state/Arrows.scala +++ b/model/inline/src/main/scala/aqua/model/inline/state/Arrows.scala @@ -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) diff --git a/model/inline/src/main/scala/aqua/model/inline/state/Exports.scala b/model/inline/src/main/scala/aqua/model/inline/state/Exports.scala index b5d98d70..a97ffaa9 100644 --- a/model/inline/src/main/scala/aqua/model/inline/state/Exports.scala +++ b/model/inline/src/main/scala/aqua/model/inline/state/Exports.scala @@ -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