1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

cgen, checker: fix comptimeselector resolution + if comptime branching improvement + comptimeselector cleanup (#17302)

This commit is contained in:
Felipe Pena
2023-02-15 06:40:11 -03:00
committed by GitHub
parent 5a8c433548
commit 039c9b2550
12 changed files with 88 additions and 62 deletions

View File

@@ -320,7 +320,7 @@ fn (e &Encoder) encode_struct[U](val U, level int, mut wr io.Writer) ! {
$if field.unaliased_typ is string {
e.encode_string(val.$(field.name).str(), mut wr)!
} $else $if field.unaliased_typ is time.Time {
parsed_time := val.$(field.name) as time.Time
parsed_time := time.parse(val.$(field.name).str()) or { time.Time{} }
e.encode_string(parsed_time.format_rfc3339(), mut wr)!
} $else $if field.unaliased_typ in [bool, $Float, $Int] {
wr.write(val.$(field.name).str().bytes())!