mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
compiler: detect and error on public init function & remove empty init functions
This commit is contained in:

committed by
Alexander Medvednikov

parent
065ce39577
commit
a06e2298f0
@ -222,6 +222,10 @@ fn (p mut Parser) fn_decl() {
|
||||
f.name = p.check_name()
|
||||
}
|
||||
f.fn_name_token_idx = p.cur_tok_index()
|
||||
// init fn
|
||||
if f.name == 'init' && f.is_public {
|
||||
p.error('init function cannot be public')
|
||||
}
|
||||
// C function header def? (fn C.NSMakeRect(int,int,int,int))
|
||||
is_c := f.name == 'C' && p.tok == .dot
|
||||
// Just fn signature? only builtin.v + default build mode
|
||||
|
Reference in New Issue
Block a user