1
0
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:
Felipe Pena 2023-03-16 16:32:52 -03:00 committed by GitHub
parent 25eabf8e2d
commit 6709b2de0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View File

@ -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) {

View 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)
}