v2: add UnsafeStmt to checker & byte/byteptr to check

pull/3937/head
Joe Conigliaro 2020-03-05 00:20:37 +11:00
parent 7daf8f8fd0
commit 8458ea40f0
2 changed files with 9 additions and 2 deletions

View File

@ -457,6 +457,11 @@ fn (c mut Checker) stmt(node ast.Stmt) {
c.return_stmt(it) c.return_stmt(it)
} }
// ast.StructDecl {} // ast.StructDecl {}
ast.UnsafeStmt {
for stmt in it.stmts {
c.stmt(stmt)
}
}
ast.VarDecl { ast.VarDecl {
typ := c.expr(it.expr) typ := c.expr(it.expr)
it.typ = typ it.typ = typ

View File

@ -398,8 +398,10 @@ pub fn (t &Table) check(got, expected Type) bool {
if got_type_sym.is_number() && exp_type_sym.is_number() { if got_type_sym.is_number() && exp_type_sym.is_number() {
return true return true
} }
// check hack in checker IndexExpr line #691 // TODO: actually check for & handle pointers with name_expr
if type_is_ptr(got) && got_type_sym.kind == .byte && exp_type_sym.kind == .byteptr { // see hack in checker IndexExpr line #691
if (got_type_sym.kind == .byte && exp_type_sym.kind == .byteptr) ||
(exp_type_sym.kind == .byte && got_type_sym.kind == .byteptr) {
return true return true
} }
// TODO // TODO