inconsistent class values when using inflight closure
Open
Nobody has claimed this yet.
🐛 bug
🐶 dogfood
🛠️ compiler
- Dominant language
- TypeScript
- Stars
- 5.4k
- Forks
- 215
- Avg merge
- 2h 9m
- Merged PRs (30d)
- 27
Description
I tried this:
running this code this.a.x has a different value before this.log() and inside that method
bring cloud;
bring util;
let queue = new cloud.Queue();
class A {
pub inflight x: str;
inflight init() {
this.x = util.nanoid();
}
}
class B {
a: A;
init() {
this.a = new A();
queue.setConsumer(inflight () => {
log("${this.a.x}");
this.log();
});
}
pub inflight log() {
log("${this.a.x}");
}
}
let b = new B();
test "" {
queue.push("123");
util.sleep(1s);
}
This happened:
pass ┌ x.main.wsim » root/env0/test:
│ JdgfhMKph7QHeHaNwg-nh
└ wABo8Lbels0iZlgQv3Hkx
I expected this:
getting the same value twice
Is there a workaround?
No response
Component
Compiler
Wing Version
No response
Node.js Version
No response
Platform(s)
No response
Anything else?
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the Wing program in the issue and compare the two logged values. Then trace the compiler handling for inflight closures and class state, using the reported mismatch as the regression condition; done means both logs consistently show the same value.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100