mirror of
https://github.com/vlang/v.git
synced 2025-09-18 11:56:57 -04:00
This commit is contained in:
parent
e1847cac9c
commit
023fd9234d
@ -415,6 +415,14 @@ fn (mut g Gen) zero_struct_field(field ast.StructField) bool {
|
|||||||
g.struct_init(default_init)
|
g.struct_init(default_init)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
} else if sym.language == .v && !field.typ.is_ptr() && sym.mod != 'builtin'
|
||||||
|
&& !sym.info.is_empty_struct() {
|
||||||
|
default_init := ast.StructInit{
|
||||||
|
typ: field.typ
|
||||||
|
}
|
||||||
|
g.write('.${field_name} = ')
|
||||||
|
g.struct_init(default_init)
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
import regex
|
||||||
|
|
||||||
|
struct RegexCache {
|
||||||
|
mut:
|
||||||
|
tag_script_start regex.RE = regex.regex_opt(r'^script.*>') or { panic(err) }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Tokenizer {
|
||||||
|
mut:
|
||||||
|
regex_cache RegexCache = RegexCache{}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn new_parser() &Parser {
|
||||||
|
mut parser := &Parser{}
|
||||||
|
return parser
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Parser {
|
||||||
|
mut:
|
||||||
|
tnzr Tokenizer
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test_struct_field_default_value_optional() {
|
||||||
|
p := new_parser()
|
||||||
|
println(p)
|
||||||
|
assert true
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user