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

table: fix alias of sumtype method_call (#11268)

This commit is contained in:
yuyi 2021-08-22 22:20:10 +08:00 committed by GitHub
parent ec196cfcd1
commit b80777df4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -475,7 +475,7 @@ pub fn (t &Table) find_field(s &TypeSymbol, name string) ?StructField {
}
}
SumType {
t.resolve_common_sumtype_fields(s)
t.resolve_common_sumtype_fields(ts)
if field := ts.info.find_field(name) {
return field
}

View File

@ -0,0 +1,16 @@
import x.json2
type MyType = json2.Any
struct Data {
prop MyType
}
fn test_alias_sumtype_method_call() {
a := '{"a":"a","b":1}'
json := json2.raw_decode(a) or { panic(err) }
data := Data{json}
json_str := data.prop.str()
println(json_str)
assert json_str == '{"a":"a","b":1}'
}