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

cgen: fix auto_str for option values (#17910)

This commit is contained in:
Felipe Pena
2023-04-10 00:56:57 -03:00
committed by GitHub
parent 220b31bfba
commit 5c439b6621
11 changed files with 93 additions and 36 deletions

View File

@@ -155,7 +155,7 @@ fn (e &Encoder) encode_struct[U](val U, level int, mut wr io.Writer) ! {
mut i := 0
mut fields_len := 0
$for field in U.fields {
if val.$(field.name).str() != 'Option(error: none)' {
if val.$(field.name).str() != 'Option(none)' {
fields_len++
}
}
@@ -171,7 +171,7 @@ fn (e &Encoder) encode_struct[U](val U, level int, mut wr io.Writer) ! {
}
$if field.is_option {
is_none := value.str() == 'Option(error: none)'
is_none := value.str() == 'Option(none)'
if !is_none {
e.encode_newline(level, mut wr)!