bring cloud;
let b = new cloud.Bucket();
class Foo {
inflight access_b() {
b.list();
}
pub inflight m() {}
}
let f = new Foo();
test "Use class but not method that access lifted object" {
f.m();
}
This happened:
fail ┌ main.wsim » root/env0/test:Use class but not method that access lifted object
│ Error: Missing environment variable: BUCKET_HANDLE_ed7b9545
│ --> ../../../tmp/wing-bundles-54j8Sq/index.js:1:9
│ 1 | "use strict";
│ | ^
│ at /tmp/wing-bundles-54j8Sq/index.js:1:9
└ at new Promise :undefined:undefined
I expected this:
to pass
Is there a workaround?
No response
Anything else?
The issue is that the simulator when creating a client for a class (Foo) creates clients for everything lifted by the class. It does so using the lift map. But since there's no reference to b in the code path from the test (the cloud.Function) then no one sets up the bucket and creating a client for no bucket fails.
This can be fixed by fixing the lift map of $inflight_init to add free floating captures and not only fields.
Wing Version
No response
Node.js Version
No response
Platform(s)
No response
Community Notes
Please vote by adding a 👍 reaction to the issue to help us prioritize.
If you are interested to work on this issue, please leave a comment.
I tried this:
Run test on sim:
This happened:
I expected this:
to pass
Is there a workaround?
No response
Anything else?
The issue is that the simulator when creating a client for a class (
Foo
) creates clients for everything lifted by the class. It does so using the lift map. But since there's no reference tob
in the code path from the test (thecloud.Function
) then no one sets up the bucket and creating a client for no bucket fails. This can be fixed by fixing the lift map of$inflight_init
to add free floating captures and not only fields.Wing Version
No response
Node.js Version
No response
Platform(s)
No response
Community Notes