nujan-ide
nujan-ide copied to clipboard
Bug: code with `foreach` loops doesn't compile
For example, the following:
import "@stdlib/deploy"; // for Deployable trait
fun mapTest(): Int {
let m: map<Int, Cell> = emptyMap();
m.set(1, beginCell().storeUint(100, 16).endCell());
m.set(2, beginCell().storeUint(200, 16).endCell());
m.set(3, beginCell().storeUint(300, 16).endCell());
m.set(4, beginCell().storeUint(400, 16).endCell());
let sum: Int = 0;
foreach (k, v in m) {
let s: Slice = v.beginParse(); // convert Cell to Slice
sum += s.loadUint(16); // sum the Slice values
}
return sum; // 1000
}
contract ForeachExample with Deployable {
// notice the lack of explicit empty init() -- a feature of Tact 1.3.0
get fun mapTest(): Int {
return mapTest();
}
}
gives non-descriptive error message while building: Error while building
. Removing the foreach
loop runs the build. Additionally, local compilation of such code works too, with or without foreach.