fix incorrect code elimination
This commit is contained in:
7
fold.cm
7
fold.cm
@@ -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
|
||||
}
|
||||
|
||||
4
parse.cm
4
parse.cm
@@ -364,6 +364,7 @@ var parse = function(tokens, src, filename, tokenizer) {
|
||||
advance()
|
||||
left = parse_assign_expr()
|
||||
pair.left = left
|
||||
pair.computed = true
|
||||
if (tok.kind == "]") advance()
|
||||
else parse_error(tok, "expected ']' after computed property")
|
||||
} else {
|
||||
@@ -1797,6 +1798,9 @@ var parse = function(tokens, src, filename, tokenizer) {
|
||||
prop = expr.list[i]
|
||||
val = prop.right
|
||||
sem_check_expr(scope, val)
|
||||
if (prop.computed) {
|
||||
sem_check_expr(scope, prop.left)
|
||||
}
|
||||
i = i + 1
|
||||
}
|
||||
return null
|
||||
|
||||
Reference in New Issue
Block a user