mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
allow non snake_case fn names in imported fns
This commit is contained in:
parent
faedebbb4e
commit
4ebf53c6e9
@ -309,18 +309,7 @@ fn (p mut Parser) fn_decl() {
|
||||
f.name = p.check_name()
|
||||
f.is_c = true
|
||||
}
|
||||
else if !p.pref.translated {
|
||||
if contains_capital(f.name) && !p.fileis('view.v') && !p.is_vgen {
|
||||
println('`$f.name`')
|
||||
p.error('function names cannot contain uppercase letters, use snake_case instead')
|
||||
}
|
||||
if f.name[0] == `_` {
|
||||
p.error('function names cannot start with `_`, use snake_case instead')
|
||||
}
|
||||
if f.name.contains('__') {
|
||||
p.error('function names cannot contain double underscores, use single underscores instead')
|
||||
}
|
||||
}
|
||||
orig_name := f.name
|
||||
// simple_name := f.name
|
||||
// user.register() => User_register()
|
||||
has_receiver := receiver_typ.len > 0
|
||||
@ -387,6 +376,19 @@ fn (p mut Parser) fn_decl() {
|
||||
if is_fn_header {
|
||||
f.is_decl = true
|
||||
}
|
||||
// Make sure the name is valid
|
||||
if !is_c && !p.pref.translated && !is_fn_header {
|
||||
if contains_capital(orig_name) && !p.fileis('view.v') && !p.is_vgen {
|
||||
//println(orig_name)
|
||||
p.error('function names cannot contain uppercase letters, use snake_case instead')
|
||||
}
|
||||
if f.name[0] == `_` {
|
||||
p.error('function names cannot start with `_`, use snake_case instead')
|
||||
}
|
||||
if orig_name.contains('__') {
|
||||
p.error('function names cannot contain double underscores, use single underscores instead')
|
||||
}
|
||||
}
|
||||
// `{` required only in normal function declarations
|
||||
if !is_c && !p.is_vh && !is_fn_header {
|
||||
p.fspace()
|
||||
|
Loading…
Reference in New Issue
Block a user