cgen: fix codegen for struct field with a shared array of points (#13222)

pull/13246/head
crthpl 2022-01-21 07:08:19 -08:00 committed by GitHub
parent ffb263c2e1
commit cbd3c14e83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -6160,7 +6160,7 @@ fn (mut g Gen) type_default(typ_ ast.Type) string {
noscan := g.check_noscan(elem_typ)
init_str := '__new_array${noscan}(0, 0, sizeof($elem_type_str))'
if typ.has_flag(.shared_f) {
atyp := '__shared__Array_${g.table.sym(elem_typ).cname}'
atyp := '__shared__$sym.cname'
return '($atyp*)__dup_shared_array(&($atyp){.mtx = {0}, .val =$init_str}, sizeof($atyp))'
} else {
return init_str

View File

@ -0,0 +1,12 @@
struct AA {
mut:
a shared []&int
}
fn test_shared_array_ptr() {
mut a := AA{}
b := 3
lock a.a {
a.a << &b
}
}