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:
parent
e7996a0792
commit
977cd0d8df
12
vlib/v/tests/aliased_field_access_test.v
Normal file
12
vlib/v/tests/aliased_field_access_test.v
Normal 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
|
||||
}
|
12
vlib/v/tests/known_errors/testdata/shared_in_alias_test.vv
vendored
Normal file
12
vlib/v/tests/known_errors/testdata/shared_in_alias_test.vv
vendored
Normal 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
|
||||
}
|
Loading…
Reference in New Issue
Block a user