fix incorrect code elimination

This commit is contained in:
2026-02-20 20:29:09 -06:00
parent 3e7b3e9994
commit f6dab3c081
2 changed files with 11 additions and 0 deletions

View File

@@ -73,6 +73,7 @@ var fold = function(ast) {
if (k == "record") {
i = 0
while (i < length(expr.list)) {
if (expr.list[i].computed && !is_pure(expr.list[i].left)) return false
if (!is_pure(expr.list[i].right)) return false
i = i + 1
}
@@ -286,6 +287,7 @@ var fold = function(ast) {
if (k == "record") {
i = 0
while (i < length(expr.list)) {
if (expr.list[i].computed) pre_scan_expr_fns(expr.list[i].left)
pre_scan_expr_fns(expr.list[i].right)
i = i + 1
}
@@ -412,6 +414,9 @@ var fold = function(ast) {
} else if (k == "record") {
i = 0
while (i < length(expr.list)) {
if (expr.list[i].computed) {
expr.list[i].left = fold_expr(expr.list[i].left, fn_nr)
}
expr.list[i].right = fold_expr(expr.list[i].right, fn_nr)
i = i + 1
}
@@ -860,6 +865,7 @@ var fold = function(ast) {
if (k == "record") {
i = 0
while (i < length(expr.list)) {
if (expr.list[i].computed) walk_expr_for_fns(expr.list[i].left)
walk_expr_for_fns(expr.list[i].right)
i = i + 1
}
@@ -949,6 +955,7 @@ var fold = function(ast) {
if (k == "record") {
i = 0
while (i < length(expr.list)) {
if (expr.list[i].computed) collect_expr_intrinsics(expr.list[i].left)
collect_expr_intrinsics(expr.list[i].right)
i = i + 1
}