File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -415,6 +415,14 @@ fn (mut g Gen) zero_struct_field(field ast.StructField) bool {
415415 g.struct_init (default_init)
416416 }
417417 return true
418+ } else if sym.language == .v && ! field.typ.is_ptr () && sym.mod != 'builtin'
419+ && ! sym.info.is_empty_struct () {
420+ default_init := ast.StructInit{
421+ typ: field.typ
422+ }
423+ g.write ('.${field_name} = ' )
424+ g.struct_init (default_init)
425+ return true
418426 }
419427 }
420428 }
Original file line number Diff line number Diff line change 1+ import regex
2+
3+ struct RegexCache {
4+ mut :
5+ tag_script_start regex.RE = regex.regex_opt (r '^script.*>' ) or { panic (err) }
6+ }
7+
8+ pub struct Tokenizer {
9+ mut :
10+ regex_cache RegexCache = RegexCache{}
11+ }
12+
13+ fn new_parser () & Parser {
14+ mut parser := & Parser{}
15+ return parser
16+ }
17+
18+ pub struct Parser {
19+ mut :
20+ tnzr Tokenizer
21+ }
22+
23+ fn test_struct_field_default_value_optional () {
24+ p := new_parser ()
25+ println (p)
26+ assert true
27+ }
You can’t perform that action at this time.
0 commit comments