Open Chriscbr opened 9 months ago
We need to start diving into these unqualified lifts.
The array/map case is another very limiting factor:
let buckets = [b1,b2,b3];
inflight () => {
for b in buckets {
b.put("data", "bang");
}
};
Oh I wish so much I could do this!
@yoav-steinberg π
Since we have lazy lifting working, an example like that should also work if you used a MutArray, which would be neat:
let buckets = MutArray [b1,b2,b3];
inflight () => {
for b in buckets {
b.put("data", "bang");
}
};
buckets.push(b4);
Added a workaround to the issue
Ideas from an offline discussion - perhaps the compiler can emit more granular emission for these kinds of cases in the SDK:
// wing
let maybeStr: str? = nil;
let maybeArr = Array<str?>[nil, "a"];
let bucket: cloud.Bucket? = nil;
let buckets = Array<cloud.Bucket>[new cloud.Bucket() as "bucket"];
new cloud.Function(inflight () => {
log(maybeStr!);
let i = 0;
log(maybeArr.at(i)!);
bucket!.put("key", "value");
if let b1 = bucket {
b.list("");
}
for b2 in buckets {
b2.put("key", "value");
}
});
producing these permissions
get _liftMap() {
return ({
"handle": [
[maybeArr, ["at"]],
[maybeStr, []],
[bucket, ["unwrap:put", "unwrap:list"]],
[buckets, ["each:put"]],
],
"$inflight_init": [
],
});
}
I tried this:
This happened:
An error from
wing compile
I expected this:
No response
Is there a workaround?
Use the original variable and unwrap it with the
!
operator:Anything else?
This works in older versions of Wing (0.50.0)
Wing Version
0.57.5
Node.js Version
20.9.0
Platform(s)
MacOS
Community Notes