From 270566055fa4cda679ed1e10542b256ad9112721 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sun, 26 Apr 2020 10:39:26 +0200 Subject: [PATCH] checker: make sure all FnDecl types are valid --- vlib/builtin/int.v | 7 +++++-- vlib/v/checker/checker.v | 9 +++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/vlib/builtin/int.v b/vlib/builtin/int.v index 13bc756449..e7f8bf79b9 100644 --- a/vlib/builtin/int.v +++ b/vlib/builtin/int.v @@ -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{ diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 04c280af37..7ecc276b8b 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -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)