-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cgen: fix update expr with embed fixed array with multiple dimensions (…
…fix vlang#23048) (vlang#23049)
- Loading branch information
Showing
3 changed files
with
75 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
module main | ||
|
||
type Mat4 = [16]f32 | ||
type Mat14 = [1][16]f32 | ||
|
||
@[heap] | ||
struct GameObject { | ||
mut: | ||
transform Mat4 | ||
transform2 Mat14 | ||
} | ||
|
||
@[heap] | ||
struct Ship { | ||
GameObject | ||
} | ||
|
||
fn Ship.new() &Ship { | ||
mut ship := &Ship{} | ||
return ship | ||
} | ||
|
||
fn (mut ship Ship) clone() &Ship { | ||
return &Ship{ | ||
...ship | ||
} | ||
} | ||
|
||
fn test_main() { | ||
mut v1 := Ship.new() | ||
v1.transform[0] = 1.0 | ||
v1.transform[15] = 2.0 | ||
v1.transform2[0][0] = 1.0 | ||
v1.transform2[0][15] = 2.0 | ||
mut v2 := v1.clone() | ||
eprintln('v1=${v1.transform}\nv2=${v2.transform}') | ||
assert v1.transform == v2.transform | ||
assert v1.transform2 == v2.transform2 | ||
assert v1.transform[0] == 1.0 | ||
assert v2.transform[0] == 1.0 | ||
assert v1.transform[15] == 2.0 | ||
assert v2.transform[15] == 2.0 | ||
|
||
assert v1.transform2[0][0] == 1.0 | ||
assert v2.transform2[0][0] == 1.0 | ||
assert v1.transform2[0][15] == 2.0 | ||
assert v2.transform2[0][15] == 2.0 | ||
} |