mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: fix selector expr with alias to ptr (#17649)
This commit is contained in:
parent
25eabf8e2d
commit
6709b2de0f
@ -3635,10 +3635,11 @@ fn (mut g Gen) selector_expr(node ast.SelectorExpr) {
|
||||
g.write(embed_name)
|
||||
}
|
||||
}
|
||||
if (node.expr_type.is_ptr() || sym.kind == .chan) && node.from_embed_types.len == 0 {
|
||||
alias_to_ptr := sym.info is ast.Alias && (sym.info as ast.Alias).parent_type.is_ptr()
|
||||
if (node.expr_type.is_ptr() || sym.kind == .chan || alias_to_ptr)
|
||||
&& node.from_embed_types.len == 0 {
|
||||
g.write('->')
|
||||
} else {
|
||||
// g.write('. /*typ= $it.expr_type */') // ${g.typ(it.expr_type)} /')
|
||||
g.write('.')
|
||||
}
|
||||
if node.expr_type.has_flag(.shared_f) {
|
||||
|
16
vlib/v/tests/selectorexpr_alias_to_ptr_test.v
Normal file
16
vlib/v/tests/selectorexpr_alias_to_ptr_test.v
Normal file
@ -0,0 +1,16 @@
|
||||
struct ABC {
|
||||
data int
|
||||
}
|
||||
|
||||
type RABC = &ABC
|
||||
|
||||
fn do(abc RABC) {
|
||||
println(abc.data)
|
||||
}
|
||||
|
||||
fn test_alias_to_ptr() {
|
||||
abc := &ABC{
|
||||
data: 5
|
||||
}
|
||||
do(abc)
|
||||
}
|
Loading…
Reference in New Issue
Block a user