This commit is contained in:
DieMyst 2023-10-25 17:41:09 +07:00
parent 983639c30a
commit e3386bf98d
4 changed files with 32 additions and 12 deletions

View File

@ -2,15 +2,15 @@ aqua A
export bugLNG260 export bugLNG260
-- func create(a: i8) -> -> i8: func create(a: i8) -> -> i8:
-- closureArrow = () -> i8: closureArrow = () -> i8:
-- <- a <- a
-- <- closureArrow <- closureArrow
--
-- func test() -> i8, i8: func test() -> i8, i8:
-- arr1 <- create(1) arr1 <- create(1)
-- arr2 <- create(2) arr2 <- create(2)
-- <- arr1(), arr2() <- arr1(), arr2()
func cmp(a: i32, b: i32, pred: i8 -> bool) -> bool: func cmp(a: i32, b: i32, pred: i8 -> bool) -> bool:
result: ?bool result: ?bool

View File

@ -2,7 +2,7 @@ module Closure declares *
import "@fluencelabs/aqua-lib/builtin.aqua" import "@fluencelabs/aqua-lib/builtin.aqua"
export LocalSrv, closureIn, closureOut, closureBig, closureOut2, lng58Bug export LocalSrv, closureIn, closureOut, closureBig, closureOut2, lng58Bug, multipleClosuresBugLNG262
service MyOp("op"): service MyOp("op"):
identity(s: string) -> string identity(s: string) -> string
@ -71,3 +71,13 @@ func lng58Bug() -> string:
waiting() waiting()
<- status! <- status!
func create(a: i8) -> -> i8:
closureArrow = () -> i8:
<- a
<- closureArrow
func multipleClosuresBugLNG262() -> i8, i8:
arr1 <- create(1)
arr2 <- create(2)
<- arr1(), arr2()

View File

@ -104,7 +104,7 @@ import { multiReturnCall } from "../examples/multiReturnCall.js";
import { declareCall } from "../examples/declareCall.js"; import { declareCall } from "../examples/declareCall.js";
import { genOptions, genOptionsEmptyString } from "../examples/optionsCall.js"; import { genOptions, genOptionsEmptyString } from "../examples/optionsCall.js";
import { lng193BugCall } from "../examples/closureReturnRename.js"; import { lng193BugCall } from "../examples/closureReturnRename.js";
import { closuresCall } from "../examples/closures.js"; import {closuresCall, multipleClosuresLNG262BugCall} from "../examples/closures.js";
import { closureArrowCaptureCall } from "../examples/closureArrowCapture.js"; import { closureArrowCaptureCall } from "../examples/closureArrowCapture.js";
import { import {
bugLNG63_2Call, bugLNG63_2Call,
@ -949,6 +949,11 @@ describe("Testing examples", () => {
expect(closuresResult).toEqual(["in", res1, res1, res2]); expect(closuresResult).toEqual(["in", res1, res1, res2]);
}, 20000); }, 20000);
it("closures.aqua bug LNG-262", async () => {
let result = await multipleClosuresLNG262BugCall();
expect(result).toEqual([1, 2]);
});
it("closureArrowCapture.aqua", async () => { it("closureArrowCapture.aqua", async () => {
let result = await closureArrowCaptureCall("input"); let result = await closureArrowCaptureCall("input");
expect(result).toEqual("call: ".repeat(4) + "input"); expect(result).toEqual("call: ".repeat(4) + "input");

View File

@ -5,6 +5,7 @@ import {
registerLocalSrv, registerLocalSrv,
closureOut2, closureOut2,
lng58Bug, lng58Bug,
multipleClosuresBugLNG262
} from "../compiled/examples/closures.js"; } from "../compiled/examples/closures.js";
import { config } from "../config.js"; import { config } from "../config.js";
@ -32,3 +33,7 @@ export async function closuresCall(): Promise<
export async function lng58CBugCall(): Promise<string> { export async function lng58CBugCall(): Promise<string> {
return lng58Bug(); return lng58Bug();
} }
export async function multipleClosuresLNG262BugCall(): Promise<[number, number]> {
return multipleClosuresBugLNG262();
}