v2: add some comments in parser & checker
parent
6de44db4eb
commit
9921897aa6
|
@ -416,6 +416,7 @@ fn (c mut Checker) stmt(node ast.Stmt) {
|
|||
for i, expr in it.exprs {
|
||||
mut field := it.fields[i]
|
||||
typ := c.expr(expr)
|
||||
// TODO: once consts are fixed update here
|
||||
c.table.register_const(table.Var{
|
||||
name: field.name
|
||||
typ: typ
|
||||
|
@ -438,6 +439,8 @@ fn (c mut Checker) stmt(node ast.Stmt) {
|
|||
if !it.is_inf && table.type_idx(typ) != table.bool_type_idx {
|
||||
c.error('non-bool used as for condition', it.pos)
|
||||
}
|
||||
// TODO: update loop var type
|
||||
// how does this work currenly?
|
||||
for stmt in it.stmts {
|
||||
c.stmt(stmt)
|
||||
}
|
||||
|
|
|
@ -1058,10 +1058,6 @@ fn (p mut Parser) for_statement() ast.Stmt {
|
|||
if p.tok.kind == .comma {
|
||||
p.check(.comma)
|
||||
val_name = p.check_name()
|
||||
// p.table.register_var(table.Var{
|
||||
// name: val_name
|
||||
// typ: table.int_type
|
||||
// })
|
||||
p.scope.register_var(ast.VarDecl{
|
||||
name: val_name
|
||||
typ: table.int_type
|
||||
|
@ -1080,9 +1076,10 @@ fn (p mut Parser) for_statement() ast.Stmt {
|
|||
p.check(.dotdot)
|
||||
high_expr = p.expr(0)
|
||||
}
|
||||
// TODO: update var type in checker
|
||||
p.scope.register_var(ast.VarDecl{
|
||||
name: var_name
|
||||
expr: cond
|
||||
// expr: cond
|
||||
})
|
||||
stmts := p.parse_block()
|
||||
// println('nr stmts=$stmts.len')
|
||||
|
@ -1357,6 +1354,7 @@ fn (p mut Parser) const_decl() ast.ConstDecl {
|
|||
// typ: typ
|
||||
}
|
||||
exprs << expr
|
||||
// TODO: once consts are fixed reg here & update in checker
|
||||
// p.table.register_const(table.Var{
|
||||
// name: name
|
||||
// // typ: typ
|
||||
|
|
Loading…
Reference in New Issue