diff --git a/vlib/v/ast/table.v b/vlib/v/ast/table.v index b5bc605639..51226a00ce 100644 --- a/vlib/v/ast/table.v +++ b/vlib/v/ast/table.v @@ -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 } diff --git a/vlib/v/tests/alias_sumtype_method_call_test.v b/vlib/v/tests/alias_sumtype_method_call_test.v new file mode 100644 index 0000000000..e85e62c30e --- /dev/null +++ b/vlib/v/tests/alias_sumtype_method_call_test.v @@ -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}' +}