1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

table: use an optional for find_fn()

This commit is contained in:
Alexander Medvednikov
2019-09-18 15:06:34 +03:00
parent 1c6cbdace5
commit 040d03912b
3 changed files with 39 additions and 40 deletions

View File

@@ -238,12 +238,15 @@ fn (p mut Parser) fn_decl() {
if !is_c && !p.builtin_mod && p.mod != 'main' && receiver_typ.len == 0 {
f.name = p.prepend_mod(f.name)
}
if p.first_pass() && p.table.known_fn(f.name) && receiver_typ.len == 0 {
existing_fn := p.table.find_fn(f.name)
if p.first_pass() && receiver_typ.len == 0 {
for {
existing_fn := p.table.find_fn(f.name) or { break }
// This existing function could be defined as C decl before (no body), then we don't need to throw an erro
if !existing_fn.is_decl {
p.error('redefinition of `$f.name`')
}
break
}
}
// Generic?
mut is_generic := false