parser: use Parser.builtin_mod instead of checking p.mod (#8137)
parent
8ee67d1c1c
commit
5185a59ac7
|
@ -254,7 +254,7 @@ fn (mut p Parser) fn_decl() ast.FnDecl {
|
|||
pos := p.tok.position()
|
||||
// TODO high order fn
|
||||
name = if language == .js { p.check_js_name() } else { p.check_name() }
|
||||
if language == .v && !p.pref.translated && util.contains_capital(name) && p.mod != 'builtin' {
|
||||
if language == .v && !p.pref.translated && util.contains_capital(name) && !p.builtin_mod {
|
||||
p.error_with_pos('function names cannot contain uppercase letters, use snake_case instead',
|
||||
pos)
|
||||
return ast.FnDecl{
|
||||
|
@ -270,7 +270,7 @@ fn (mut p Parser) fn_decl() ast.FnDecl {
|
|||
}
|
||||
}
|
||||
// cannot redefine buildin function
|
||||
if !is_method && p.mod != 'builtin' && name in builtin_functions {
|
||||
if !is_method && !p.builtin_mod && name in builtin_functions {
|
||||
p.error_with_pos('cannot redefine builtin function `$name`', pos)
|
||||
return ast.FnDecl{
|
||||
scope: 0
|
||||
|
|
|
@ -250,7 +250,7 @@ pub fn (mut p Parser) parse_any_type(language table.Language, is_ptr bool, check
|
|||
name = p.expr_mod + '.' + name
|
||||
} else if name in p.imported_symbols {
|
||||
name = p.imported_symbols[name]
|
||||
} else if p.mod != 'builtin' && name.len > 1 && name !in p.table.type_idxs {
|
||||
} else if !p.builtin_mod && name.len > 1 && name !in p.table.type_idxs {
|
||||
// `Foo` in module `mod` means `mod.Foo`
|
||||
name = p.mod + '.' + name
|
||||
}
|
||||
|
|
|
@ -65,9 +65,7 @@ fn (mut p Parser) struct_decl() ast.StructDecl {
|
|||
p.error('`$p.tok.lit` lacks body')
|
||||
return ast.StructDecl{}
|
||||
}
|
||||
if language == .v &&
|
||||
p.mod != 'builtin' && name.len > 0 && !name[0].is_capital() && !p.pref.translated
|
||||
{
|
||||
if language == .v && !p.builtin_mod && name.len > 0 && !name[0].is_capital() && !p.pref.translated {
|
||||
p.error_with_pos('struct name `$name` must begin with capital letter', name_pos)
|
||||
return ast.StructDecl{}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue