v2: for in checker
parent
39c4842bf9
commit
19520ccf4e
|
@ -209,6 +209,7 @@ pub fn (c byte) is_capital() bool {
|
|||
|
||||
pub fn (b []byte) clone() []byte {
|
||||
mut res := [byte(0)].repeat(b.len)
|
||||
//mut res := make([]byte, {repeat:b.len})
|
||||
for i := 0; i < b.len; i++ {
|
||||
res[i] = b[i]
|
||||
}
|
||||
|
|
|
@ -348,6 +348,7 @@ pub:
|
|||
var string
|
||||
cond Expr
|
||||
stmts []Stmt
|
||||
pos token.Position
|
||||
}
|
||||
|
||||
pub struct ForCStmt {
|
||||
|
|
|
@ -994,7 +994,7 @@ fn (p mut Parser) for_statement() ast.Stmt {
|
|||
stmts := p.parse_block()
|
||||
// println('nr stmts=$stmts.len')
|
||||
p.close_scope()
|
||||
return ast.ForStmt{
|
||||
return ast.ForInStmt{
|
||||
stmts: stmts
|
||||
pos: p.tok.position()
|
||||
}
|
||||
|
|
|
@ -377,15 +377,20 @@ pub fn (t &Table) check(got, expected Type) bool {
|
|||
if got_type_sym.is_number() && exp_type_sym.is_number() {
|
||||
return true
|
||||
}
|
||||
// TODO
|
||||
// if got_type_sym.kind == .array && exp_type_sym.kind == .array {
|
||||
// return true
|
||||
// }
|
||||
if got_type_sym.kind == .array_fixed && exp_type_sym.kind == .byteptr {
|
||||
info := got_type_sym.info as ArrayFixed
|
||||
if type_idx(info.elem_type) == byte_type_idx {
|
||||
return true
|
||||
}
|
||||
}
|
||||
// if expected.name == 'array' {
|
||||
// return true
|
||||
// }
|
||||
// TODO
|
||||
if exp_type_sym.name == 'array' || got_type_sym.name == 'array' {
|
||||
return true
|
||||
}
|
||||
if got_idx != exp_idx {
|
||||
// && got.typ.name != expected.typ.name*/
|
||||
return false
|
||||
|
|
Loading…
Reference in New Issue