You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
final n = Std.int(Mathf.random(3) + 1);
final cells = [for (i in 0...n) "A"]
.concat([for (i in 0...n) "B"])
.concat([for (i in 0...n) "C"]);
Lib.trace(cells);
var _n = (random(3) + 1 | 0);
var __g = [];
repeat (_n) array_push(_cells, "A");
var __g = [];
repeat (_n) array_push(__g, "B");
var _cells1 = gml_internal_ArrayImpl.concat(_cells, __g);
var _cells = [];
repeat (_n) array_push(__g, "C");
show_debug_message(gml_internal_ArrayImpl.concat(_cells1, __g));
var _cells = []; Declared after first using var __g = []; Declared two times
Looks like order of declare variables inverted.
The text was updated successfully, but these errors were encountered:
Technically the generated structure is a bit of a mess - you can see it if you build it for JS,
class Test {
static function main() {
final n = Std.int(Std.random(3) + 1);
final cells = [for (i in 0...n) "A"]
.concat([for (i in 0...n) "B"])
.concat([for (i in 0...n) "C"]);
trace(cells);
}
}
Output
var Test = function() { };
Test.main = function() {
var n = Std.random(3) + 1 | 0;
var _g = [];
var _g1 = 0;
var _g2 = n;
while(_g1 < _g2) {
var i = _g1++;
_g.push("A");
}
var cells = _g;
var _g = [];
var _g1 = 0;
var _g2 = n;
while(_g1 < _g2) {
var i = _g1++;
_g.push("B");
}
var cells1 = cells.concat(_g);
var _g = [];
var _g1 = 0;
var _g2 = n;
while(_g1 < _g2) {
var i = _g1++;
_g.push("C");
}
var cells = cells1.concat(_g);
console.log("src/Test.hx:13:",cells);
};
I have a little optimizer that removes one-off variables, but it struggles with this piece since the compiler re-uses and re-declares the variables. You can disable it using -D sf_no_opt_auto_var
Me again but with a real bug
var _cells = [];
Declared after first usingvar __g = [];
Declared two timesLooks like order of declare variables inverted.
The text was updated successfully, but these errors were encountered: