mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: fix inability to access aliased struct fields (#5861)
This commit is contained in:
parent
74d70b8719
commit
e5a508c0d7
@ -707,7 +707,11 @@ fn (mut c Checker) fail_if_immutable(expr ast.Expr) (string, token.Position) {
|
||||
c.error('0 type in SelectorExpr', expr.pos)
|
||||
return '', pos
|
||||
}
|
||||
typ_sym := c.table.get_type_symbol(c.unwrap_generic(expr.expr_type))
|
||||
mut typ_sym := c.table.get_type_symbol(c.unwrap_generic(expr.expr_type))
|
||||
if typ_sym.kind == .alias {
|
||||
alias_info := typ_sym.info as table.Alias
|
||||
typ_sym = c.table.get_type_symbol(alias_info.parent_type)
|
||||
}
|
||||
match typ_sym.kind {
|
||||
.struct_ {
|
||||
struct_info := typ_sym.info as table.Struct
|
||||
|
@ -23,3 +23,15 @@ fn test_type_alias_v2() {
|
||||
g := Myf64_2(10.4)
|
||||
assert g + 0.5 == 10.9
|
||||
}
|
||||
|
||||
struct Mystruct {
|
||||
mut:
|
||||
i int
|
||||
}
|
||||
type Mystruct_2 Mystruct
|
||||
|
||||
fn test_type_alias_struct() {
|
||||
mut s := Mystruct_2{}
|
||||
s.i = 10
|
||||
assert s.i + 100 == 110
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user