1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

cgen: better alias handling for references/shared (#17656)

This commit is contained in:
Louis Brunner 2023-03-20 16:35:45 +00:00 committed by GitHub
parent e7996a0792
commit 977cd0d8df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

View File

@ -0,0 +1,12 @@
struct Data {
field int
}
type AliasWithPtr = &Data
fn test_aliased_field_access_test() {
data_with_ptr := AliasWithPtr(&Data{
field: 1
})
assert data_with_ptr.field == 1
}

View File

@ -0,0 +1,12 @@
struct Data {
field int
}
type AliasWithShared = shared Data
fn test_shared_in_alias() {
data_with_shared := AliasWithShared(&Data{
field: 1
})
assert data_with_shared.field == 1
}