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:
parent
ec196cfcd1
commit
b80777df4b
@ -475,7 +475,7 @@ pub fn (t &Table) find_field(s &TypeSymbol, name string) ?StructField {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
SumType {
|
SumType {
|
||||||
t.resolve_common_sumtype_fields(s)
|
t.resolve_common_sumtype_fields(ts)
|
||||||
if field := ts.info.find_field(name) {
|
if field := ts.info.find_field(name) {
|
||||||
return field
|
return field
|
||||||
}
|
}
|
||||||
|
16
vlib/v/tests/alias_sumtype_method_call_test.v
Normal file
16
vlib/v/tests/alias_sumtype_method_call_test.v
Normal 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}'
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user