Bytecode interpreter RET_CHECK failure for missing caller bindings
- Dominant language
- C++
- Stars
- 1.9k
- Forks
- 283
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 135
Description
**Describe the bug**
This is a weird scenario to describe succinctly, but given an unroll_for, a nested for with iterable range depending on the outer index, and a parametric function, you get a strange error about missing caller bindings.
**To Reproduce**
```
import std;
fn foo() -> u32 {
for (_, result): (u32, u32) in range(u32:0, N) {
unroll_for! (j, result): (u32, u32) in range(u32:0, u32:10) {
for (k, _): (u32, u32) in range(u32:0, std::upow(u32:2, j)) {
k
}(result)
}(result)
}(u32:0)
}
#[test]
fn foo_test() { assert_eq(foo(), u32:511); }
```
If the function is not parametric, and N is replaced by `u32:10`, the issue does not appear. If the inner range is not a function, and just `j`, the issue does not appear.
**Expected behavior**
Should behave like the non-parametric version which does not generate the same error.
```
fn foo() -> u32 {
for (_, result): (u32, u32) in range(u32:0, u32:10) {
unroll_for! (j, result): (u32, u32) in range(u32:0, u32:10) {
for (k, _): (u32, u32) in range(u32:0, std::upow(u32:2, j)) {
k
}(result)
}(result)
}(u32:0)
}
```
Contributor guide
Assessment
This issue has not been assessed yet.