I found that there was indeed a bug with closure variable initialization. This bug is now fixed. This will hopefully solve the problem you found in ast-passes.
- Maxime
After applying a few workarounds to advance in the bootstrap, I discovered that Tachyon is not compiling pass 4 of parser/ast-passes.js correctly. Specifically the part that handles the ForVarStatement had to be rewritten like this, otherwise the variable accum would be equal to undefined instead of null:
else if (ast instanceof ForVarStatement) { var accum; // CHANGED, used to be: var accum = null; accum = undefined; // CHANGED for (var i=ast.decls.length-1; i>=0; i--) { var decl = ast.decls[i]; this.add_variable(decl.id, false); if (decl.initializer !== null) { decl.initializer = this.walk_expr(decl.initializer); var init = new OpExpr(decl.loc, op2_table[EQUAL_CAT], [new Ref(decl.id.loc, decl.id), decl.initializer]); if (accum === undefined) // CHANGED accum = init; else accum = new OpExpr(decl.loc, op2_table[COMMA_CAT], [init,
(accum===undefined)?null:accum]); // CHANGED } } ast.expr2 = this.walk_expr(ast.expr2); ast.expr3 = this.walk_expr(ast.expr3); ast.statement = this.walk_statement(ast.statement); return new ForStatement(ast.loc, (accum===undefined)?null:accum, // CHANGED ast.expr2, ast.expr3, ast.statement); }
Someone with a better understanding of the compiler should debug this.
Marc
Tachyon-list mailing list Tachyon-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/tachyon-list