-
Notifications
You must be signed in to change notification settings - Fork 88
Draft grammar to permit nullable types as array element types. #1297
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
Draft
gafter
wants to merge
4
commits into
dotnet:draft-v8
Choose a base branch
from
gafter:neal_arrays_of_nullable
base: draft-v8
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.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
3 changes: 3 additions & 0 deletions
3
tools/GrammarTesting/Tests/Parsing/Samples/v8/Arrays of nullables/ReadMe.md
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,3 @@ | ||
# Sample: Arrays of NRT | ||
|
||
Samples for nullable arrays, arrays of nullables, and nullable arrays of nullables. |
1 change: 1 addition & 0 deletions
1
tools/GrammarTesting/Tests/Parsing/Samples/v8/Arrays of nullables/_Sample_Options.txt
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 @@ | ||
-ms Rules -rt |
36 changes: 36 additions & 0 deletions
36
tools/GrammarTesting/Tests/Parsing/Samples/v8/Arrays of nullables/sample.cs
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,36 @@ | ||
class ArraysOfNullable | ||
{ | ||
class A { } | ||
|
||
void ArraysOfNullable() | ||
{ | ||
A[] p_1 = new A[5]; // Array of non-nullable A all elements inited to null (oops) | ||
A[]? q_1 = null; // Nullable array of non-nullable A, array inited to null | ||
A?[] r_1 = new A[5]; // Array of nullable A all elements inited to null | ||
A?[]? s_1 = null; // Nullable array of nullable A, array inited to null | ||
|
||
string[] p_2 = new string[5]; // Array of non-nullable string all elements inited to null (oops) | ||
string[]? q_2 = null; // Nullable array of non-nullable string, array inited to null | ||
string?[] r_2 = new string[5]; // Array of nullable string all elements inited to null | ||
string?[]? s_2 = null; // Nullable array of nullable string, array inited to null | ||
|
||
int[] p_3 = new int[5]; // Array of non-nullable int all elements inited to 0 | ||
int[]? q_3 = null; // Nullable array of non-nullable int, array inited to null | ||
int?[] r_3 = new int[5]; // Array of nullable int all elements inited to null | ||
int?[]? s_3 = null; // Nullable array of nullable int, array inited to null | ||
|
||
dynamic[] p_4 = new dynamic[5]; // Array of non-nullable dynamic all elements inited to 0 | ||
dynamic[]? q_4 = null; // Nullable array of non-nullable dynamic, array inited to null | ||
dynamic?[] r_4 = new dynamic[5]; // Array of nullable dynamic all elements inited to null | ||
dynamic?[]? s_4 = null; // Nullable array of nullable dynamic, array inited to null | ||
|
||
A[][,] p_5 = new A[1][1,1]; // Array of two-dimensional array | ||
A[][,]? q_5 = null; // Array of two-dimensional array | ||
A[]?[,] r_5 = new A[]?[1,1]; // Two dimensional array of array | ||
A[]?[,]? s_5 = null; // Two dimensional array of array | ||
A?[][,] t_5 = new A[1][1,1]; // Array of two-dimensional array | ||
A?[][,]? u_5 = null; // Array of two-dimensional array | ||
A?[]?[,] v_5 = new A[]?[1,1]; // Two dimensional array of array | ||
A?[]?[,]? w_5 = null; // Two dimensional array of array | ||
} | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this allow
int??[]
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, because a nullable type isn't a
non_array_type
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm reading it right,
non_array_type
includesvalue_type
which includesnullable_value_type
which I believeint?
would be.