-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
ast, cgen, assign: fix fixed array alias: nested empty init, ref init and reassign #27969
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rilaaax
wants to merge
6
commits into
vlang:master
Choose a base branch
from
rilaaax:fix-fixed-array-alias-init_ref_assign
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0b91f23
ast: fix nested fixed array of empty struct init
rilaaax ea7e2c9
cgen: fix fixed array of empty structs reference init
rilaaax 218af4d
assign: fix reassign of fixed array alias
rilaaax 285e96e
fix option alias fixed array init
rilaaax 7845018
fix assign option alias fixed array
rilaaax 7afd043
fix fixed array of struct return type for option and result
rilaaax File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,23 @@ | ||
| struct Box {} | ||
|
|
||
| type Arr = [2]Box | ||
|
|
||
| fn empty_ident_to_result(a Arr) !Arr { | ||
| return a | ||
| } | ||
|
|
||
| fn empty_ident_to_option(a Arr) ?Arr { | ||
| return a | ||
| } | ||
|
|
||
| fn test_return_ident_fixed_array_of_empty_struct_as_result() { | ||
| a := Arr{} | ||
| b := empty_ident_to_result(a) or { panic(err) } | ||
| assert b.len == 2 | ||
| } | ||
|
|
||
| fn test_return_ident_fixed_array_of_empty_struct_as_option() { | ||
| a := Arr{} | ||
| b := empty_ident_to_option(a) or { panic('unexpected none') } | ||
| assert b.len == 2 | ||
| } |
25 changes: 25 additions & 0 deletions
25
vlib/v/tests/options/option_fixed_array_alias_assign_test.v
This file contains hidden or 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,25 @@ | ||
| struct Box {} | ||
|
|
||
| type Arr = [2]Box | ||
|
|
||
| fn test_option_fixed_array_alias_assign_struct_init_literal() { | ||
| mut a := ?Arr(none) | ||
|
|
||
| a = Arr{} | ||
| assert a != none | ||
| } | ||
|
|
||
| fn test_option_fixed_array_alias_assign_option_cast() { | ||
| mut a := ?Arr(Arr{}) | ||
|
|
||
| a = ?Arr(none) | ||
| assert a == none | ||
| } | ||
|
|
||
| fn test_option_fixed_array_alias_assign_plain_ident() { | ||
| mut a := ?Arr(none) | ||
| mut plain := Arr{} | ||
|
|
||
| a = plain | ||
| assert a != none | ||
| } |
11 changes: 11 additions & 0 deletions
11
vlib/v/tests/options/option_struct_init_fixed_array_alias_test.v
This file contains hidden or 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,11 @@ | ||
| struct Box {} | ||
|
|
||
| type Arr = [2]Box | ||
|
|
||
| fn test_option_struct_init_fixed_array_alias() { | ||
| a := ?Arr{} | ||
| assert a == none | ||
|
|
||
| b := ?Arr(none) | ||
| assert b == none | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.