Skip to content
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

Nullable annotation is no longer part of array rank specifier #32431

Merged
merged 8 commits into from
Jan 25, 2019

Conversation

gafter
Copy link
Member

@gafter gafter commented Jan 13, 2019

Fixes #32290 and other related issues

@gafter gafter added the PR For Personal Review Only The PR doesn’t require anyone other than the developer to review it. label Jan 13, 2019
@gafter gafter self-assigned this Jan 13, 2019
@gafter gafter requested a review from a team as a code owner January 13, 2019 22:58
@gafter gafter added this to Working/In Review in Compiler: Gafter Jan 13, 2019
@jcouv jcouv added this to the 16.0.P2 milestone Jan 14, 2019
@cston
Copy link
Member

cston commented Jan 14, 2019

        if (typeOpt.IsNull)

Check should be moved to ShouldPrintNullableAnnotation. #Resolved


Refers to: src/Compilers/CSharp/Portable/SymbolDisplay/SymbolDisplayVisitor.Types.cs:77 in fb6b088. [](commit_id = fb6b088, deletion_comment = False)

@gafter
Copy link
Member Author

gafter commented Jan 14, 2019

What is the point of adding PR For Personal Review Only if y'all are going to ignore it? ;)

Anyway, thanks for the feedback. #Closed

@gafter gafter changed the base branch from master to dev16.0-preview2 January 14, 2019 21:10
@jcouv
Copy link
Member

jcouv commented Jan 14, 2019

What is the point of adding PR For Personal Review Only if y'all are going to ignore it? ;)

In my experience, PRs marked as "personal" get reviewed the fastest. There may be some yet-to-be-named law for that ;-) #Closed

…d into semantic analysis

- Move error checking for invalid array dimensions out of the parser and into semantic analysis
- Diagnose `e is string?`
Fixes dotnet#32025
@gafter gafter changed the base branch from dev16.0-preview2 to master January 16, 2019 00:12
@gafter gafter modified the milestones: 16.0.P2, 16.0.P3 Jan 16, 2019
@@ -5037,6 +5037,12 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<data name="ERR_PatternNullableType" xml:space="preserve">
<value>It is not legal to use nullable type '{0}' in a pattern; use the underlying type '{1}' instead.</value>
</data>
<data name="ERR_IsNullableType" xml:space="preserve">
<value>It is not legal to use nullable type '{0}?' in an is-type expression; use the underlying type '{0}' instead.</value>
Copy link
Member

@agocke agocke Jan 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add "because is never matches null" to make it clear why it's illegal. I suspect people trying to do this may not have the correct mental model. #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not the reason. This is only given for nullable reference types. The reason is that it is a runtime check, and nullable reference types do not exist at runtime. I'll clarify.


In reply to: 249944779 [](ancestors = 249944779)

…nce* types are illegal

in an is-type or as-type expression.
@gafter
Copy link
Member Author

gafter commented Jan 22, 2019

I believe I have responded to all comments. Are there any further comments? #Resolved

@gafter gafter requested a review from a team as a code owner January 22, 2019 23:54
Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM Thanks (iteration 8)

}

done:;
Copy link
Member

@cston cston Jan 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

; [](start = 5, length = 1)

Minor point: ; is unnecessary. #Resolved

@@ -3454,7 +3454,7 @@ static void Test(int arg1, (byte, byte) arg2)
}
";
var tree = SyntaxFactory.ParseSyntaxTree(source, options: TestOptions.Regular);
Assert.Equal(false, tree.GetRoot().ContainsDiagnostics);
tree.GetDiagnostics().Verify();
}
Copy link
Member

@cston cston Jan 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

} [](start = 8, length = 1)

Are we testing: _ = new(int, int)?{}; ? #Resolved

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also test error recovery for: _ = new (int, int) ? (x) : y;


In reply to: 251128787 [](ancestors = 251128787)

result = ScanTypeFlags.NullableType;
break;
case SyntaxKind.AsteriskToken
when lastTokenOfType.Kind != SyntaxKind.CloseBracketToken: // don't allow `Type[]*`
Copy link
Member

@cston cston Jan 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type[]* [](start = 103, length = 7)

Are we testing this case? #Resolved

case ParseTypeMode.NewExpression:
// A nullable qualifier is permitted as part of the type in a `new` expression.
// e.g. `new int?()` is allowed. It creates a null value of type `Nullable<int>`.
// But the object initializer syntax `new int? {}` is not permitted.
Copy link
Member

@cston cston Jan 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new int? {} is not permitted [](start = 65, length = 30)

I'm confused. Should new int? { } be permitted? (It is today.)

The comment says it's not permitted but the return expression allows {. #Resolved

@@ -16,15 +16,8 @@ private void VisitTypeSymbolWithAnnotations(TypeSymbolWithAnnotations type, Abst
var visitor = (SymbolDisplayVisitor)(visitorOpt ?? this.NotFirstVisitor);
Copy link
Member

@cston cston Jan 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(SymbolDisplayVisitor) [](start = 26, length = 22)

The cast is no longer necessary. #Resolved

{
if (!this.isFirstSymbolVisited)
if (!(arrayType is null) && !this.isFirstSymbolVisited)
Copy link
Member

@cston cston Jan 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(arrayType is null [](start = 21, length = 18)

while condition already checked arrayType != null. #Resolved

@@ -31,7 +31,11 @@ class C
comp.VerifyDiagnostics(
// (7,52): error CS1586: Array creation must have array size or array initializer
// Expression<Action<dynamic>> e = x => new object[](x);
Diagnostic(ErrorCode.ERR_MissingArraySize, "[]"));
Diagnostic(ErrorCode.ERR_MissingArraySize, "[]").WithLocation(7, 52),
// (7,42): error CS0149: Method name expected
Copy link
Member

@cston cston Jan 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error CS0149: Method name expected [](start = 27, length = 34)

This cascading error seems unfortunate. The first error makes sense but this second error seems incorrect given the first. #Resolved

@jasonmalinowski jasonmalinowski changed the base branch from master to dev16.0-preview3 January 25, 2019 22:03
}
}
EOF();
}
Copy link
Member

@cston cston Jan 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

} [](start = 8, length = 1)

Please test with multiple dimensional array after ?:

new object[1]?[2,3]?[]
``` #Resolved

Copy link
Member

@cston cston left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Several comments and some test suggestions, but not blocking.

TypeSyntax elementTypeSyntax = arrayTypeSyntax.ElementType;
var elementType = BindType(elementTypeSyntax, diagnostics);
var elementTypeSyntax = arrayTypeSyntax.ElementType;
var arrayType = (ArrayTypeSymbol)BindArrayType(arrayTypeSyntax, diagnostics, permitDimensions: true, basesBeingResolved: null).TypeSymbol;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BindArrayType [](start = 45, length = 13)

I think this change is the cause of #33945
We didn't use to check whether the type is IsRestrictedType, but now we do (inside BindArrayType).

xoofx pushed a commit to stark-lang/stark-roslyn that referenced this pull request Apr 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants