checker: make sure all FnDecl types are valid

pull/4606/head
Alexander Medvednikov 2020-04-26 10:39:26 +02:00
parent 3c08f655af
commit 270566055f
2 changed files with 14 additions and 2 deletions

View File

@ -266,7 +266,7 @@ pub fn (nn u16) hex() string {
if nn == 0 {
return '0'
}
mut n := nn
max := 5
mut buf := malloc(max + 1)
@ -320,7 +320,7 @@ pub fn (nn u64) hex() string {
if nn == 0 {
return '0'
}
mut n := nn
max := 18
mut buf := malloc(max + 1)
@ -356,6 +356,8 @@ pub fn (a []byte) contains(val byte) bool {
return false
}
/*
pub fn (c rune) str() string {
fst_byte := int(c)>>8 * 3 & 0xff
len := utf8_char_len(fst_byte)
@ -369,6 +371,7 @@ pub fn (c rune) str() string {
str.str[len] = `\0`
return str
}
*/
pub fn (c byte) str() string {
mut str := string{

View File

@ -1217,6 +1217,15 @@ fn (mut c Checker) stmt(node ast.Stmt) {
// c.warn('duplicate method `$it.name`', it.pos)
// }
// }
if !it.is_c {
// Make sure all types are valid
for arg in it.args {
sym := c.table.get_type_symbol(arg.typ)
if sym.kind == .placeholder {
c.error('unknown type `$sym.name`', it.pos)
}
}
}
c.expected_type = table.void_type
c.fn_return_type = it.return_type
c.stmts(it.stmts)