parser: allow `arr = []` instead of `arr = []string`
parent
8d4ef822b6
commit
5df5f97daf
|
@ -569,6 +569,9 @@ pub fn (v &V) v_files_from_dir(dir string) []string {
|
|||
// Parses imports, adds necessary libs, and then user files
|
||||
pub fn (v mut V) add_v_files_to_compile() {
|
||||
mut builtin_files := v.get_builtin_files()
|
||||
if v.pref.is_bare {
|
||||
builtin_files = []string
|
||||
}
|
||||
// Builtin cache exists? Use it.
|
||||
builtin_vh := '$v_modules_path${os.path_separator}vlib${os.path_separator}builtin.vh'
|
||||
if v.pref.is_cache && os.file_exists(builtin_vh) {
|
||||
|
|
|
@ -2424,12 +2424,15 @@ fn (p mut Parser) array_init() string {
|
|||
}
|
||||
p.check(.rsbr)
|
||||
// type after `]`? (e.g. "[]string")
|
||||
if p.tok != .name && i == 0 {
|
||||
if p.tok != .name && i == 0 && !p.expected_type.starts_with('array_') {
|
||||
p.error('specify array type: `[]typ` instead of `[]`')
|
||||
}
|
||||
if p.tok == .name && i == 0 {
|
||||
// vals.len == 0 {
|
||||
typ = p.get_type()
|
||||
} else if p.expected_type.starts_with('array_') {
|
||||
// allow `known_array = []`
|
||||
typ = p.expected_type[6..]
|
||||
}
|
||||
// ! after array => no malloc and no copy
|
||||
no_alloc := p.tok == .not
|
||||
|
|
Loading…
Reference in New Issue