mirror of
https://github.com/fluencelabs/aqua.git
synced 2024-12-04 22:50:18 +00:00
fix(compiler): Bug in renaming [LNG-346] (#1094)
This commit is contained in:
parent
6e9689945d
commit
d7fef3db5f
@ -1,12 +1,48 @@
|
||||
aqua Job declares *
|
||||
aqua Main
|
||||
|
||||
import someString from "hack"
|
||||
use timeout, someString from "hack.aqua" as P
|
||||
export bugLNG346
|
||||
|
||||
export timeout
|
||||
ability Promise:
|
||||
yield() -> string
|
||||
|
||||
func timeout() -> string:
|
||||
res <- P.timeout()
|
||||
b = someString()
|
||||
a = P.someString()
|
||||
func done_nil() -> string:
|
||||
<- ""
|
||||
|
||||
func done() -> Promise:
|
||||
<- Promise(yield = done_nil)
|
||||
|
||||
ability Compute:
|
||||
yield() -> string
|
||||
|
||||
alias WorkerYield: -> string
|
||||
alias Yield: WorkerYield -> Promise
|
||||
|
||||
func wait_for() -> Yield:
|
||||
wait = func (cb: -> string) -> Promise:
|
||||
yield = func () -> string:
|
||||
e <- cb()
|
||||
<- e
|
||||
<- Promise(yield = yield)
|
||||
<- wait
|
||||
|
||||
ability Function:
|
||||
run(dealId: string) -> string
|
||||
|
||||
func simple{Compute}(yield: Yield) -> Function:
|
||||
deal_run = func () -> string:
|
||||
c_yield = func () -> string:
|
||||
<- Compute.yield()
|
||||
yieeld <- yield(c_yield)
|
||||
res <- yieeld.yield()
|
||||
<- res
|
||||
<- Function(run = deal_run)
|
||||
|
||||
func bugLNG346() -> string:
|
||||
res: *string
|
||||
yieeld = func () -> string:
|
||||
res <<- "hello"
|
||||
<- ""
|
||||
c = Compute(yield = yieeld)
|
||||
fn = simple{c}(wait_for())
|
||||
r <- fn.run("")
|
||||
<- res!
|
@ -1,4 +1,4 @@
|
||||
module DeclareModule declares decl_foo, decl_bar, SuperFoo, DECLARE_CONST, DECLARE_CONST2
|
||||
aqua DeclareModule declares decl_foo, decl_bar, SuperFoo, DECLARE_CONST, DECLARE_CONST2
|
||||
export SuperFoo
|
||||
|
||||
const DECLARE_CONST = "declare_const"
|
||||
|
48
integration-tests/aqua/examples/abilitiesClosureRename.aqua
Normal file
48
integration-tests/aqua/examples/abilitiesClosureRename.aqua
Normal file
@ -0,0 +1,48 @@
|
||||
aqua AbilitiesClosureRename
|
||||
|
||||
export bugLNG346
|
||||
|
||||
ability Promise:
|
||||
yield() -> string
|
||||
|
||||
func done_nil() -> string:
|
||||
<- ""
|
||||
|
||||
func done() -> Promise:
|
||||
<- Promise(yield = done_nil)
|
||||
|
||||
ability Compute:
|
||||
yield() -> string
|
||||
|
||||
alias WorkerYield: -> string
|
||||
alias Yield: WorkerYield -> Promise
|
||||
|
||||
func wait_for() -> Yield:
|
||||
wait = func (cb: -> string) -> Promise:
|
||||
yield = func () -> string:
|
||||
e <- cb()
|
||||
<- e
|
||||
<- Promise(yield = yield)
|
||||
<- wait
|
||||
|
||||
ability Function:
|
||||
run(dealId: string) -> string
|
||||
|
||||
func simple{Compute}(yield: Yield) -> Function:
|
||||
deal_run = func () -> string:
|
||||
c_yield = func () -> string:
|
||||
<- Compute.yield()
|
||||
yieeld <- yield(c_yield)
|
||||
res <- yieeld.yield()
|
||||
<- res
|
||||
<- Function(run = deal_run)
|
||||
|
||||
func bugLNG346() -> string:
|
||||
res: *string
|
||||
yieeld = func () -> string:
|
||||
res <<- "hello"
|
||||
<- ""
|
||||
c = Compute(yield = yieeld)
|
||||
fn = simple{c}(wait_for())
|
||||
r <- fn.run("")
|
||||
<- res!
|
@ -41,6 +41,7 @@ import {
|
||||
returnSrvAsAbilityCall,
|
||||
} from "../examples/abilityCall.js";
|
||||
import { bugLNG314Call, bugLNG338Call } from "../examples/abilityClosureCall.js";
|
||||
import { bugLNG346Call } from "../examples/abilityClosureRenameCall.js";
|
||||
import {
|
||||
nilLengthCall,
|
||||
nilLiteralCall,
|
||||
@ -670,6 +671,11 @@ describe("Testing examples", () => {
|
||||
expect(result).toEqual("job done");
|
||||
});
|
||||
|
||||
it("abilitiesClosureRename.aqua bug LNG-346", async () => {
|
||||
let result = await bugLNG346Call();
|
||||
expect(result).toEqual("hello");
|
||||
});
|
||||
|
||||
it("functors.aqua LNG-119 bug", async () => {
|
||||
let result = await bugLng119Call();
|
||||
expect(result).toEqual([1]);
|
||||
|
@ -0,0 +1,8 @@
|
||||
import {
|
||||
bugLNG346
|
||||
} from "../compiled/examples/abilitiesClosureRename.js";
|
||||
|
||||
export async function bugLNG346Call(): Promise<string> {
|
||||
return await bugLNG346();
|
||||
}
|
||||
|
@ -507,9 +507,7 @@ object ArrowInliner extends Logging {
|
||||
* are prohibited because they are used inside **this function**.
|
||||
*/
|
||||
defineNames <- StateT.liftF(
|
||||
fn.body.definesVarNames.map(
|
||||
_ -- argNames -- capturedNames
|
||||
)
|
||||
fn.body.definesVarNames
|
||||
)
|
||||
defineRenames <- Mangler[S].findAndForbidNames(defineNames)
|
||||
canonStreamsWithNames <- canonStreamVariables(args)
|
||||
|
Loading…
Reference in New Issue
Block a user