Skip to content

[features/param-nullchecking] The BangBang Update#46520

Merged
kevinsun-dev merged 30 commits intodotnet:features/param-nullcheckingfrom
kevinsun-dev:features/param-nullchecking-fixes
Aug 11, 2020
Merged

[features/param-nullchecking] The BangBang Update#46520
kevinsun-dev merged 30 commits intodotnet:features/param-nullcheckingfrom
kevinsun-dev:features/param-nullchecking-fixes

Conversation

@kevinsun-dev
Copy link
Copy Markdown
Contributor

Updated features/param-nullchecking for new !! syntax.

  • Updated Lexer
  • Updated Parser
  • Updated Syntax.xml
  • Updated Errors
  • Updated Tests

@kevinsun-dev kevinsun-dev changed the base branch from master to features/param-nullchecking August 3, 2020 19:42
@kevinsun-dev kevinsun-dev reopened this Aug 5, 2020
@kevinsun-dev kevinsun-dev force-pushed the features/param-nullchecking-fixes branch from 1b210e2 to 42fa7f4 Compare August 5, 2020 20:27
@333fred 333fred closed this Aug 5, 2020
@333fred 333fred reopened this Aug 5, 2020
@sharwell sharwell marked this pull request as ready for review August 5, 2020 20:57
@sharwell sharwell requested a review from a team as a code owner August 5, 2020 20:57
@sharwell sharwell marked this pull request as draft August 5, 2020 20:57
@333fred 333fred removed the request for review from a team August 5, 2020 21:02
@kevinsun-dev kevinsun-dev marked this pull request as ready for review August 6, 2020 17:01
@333fred
Copy link
Copy Markdown
Member

333fred commented Aug 7, 2020

Done review pass (commit 23). The implementation is looking mostly good, but we need more tests. #Closed

@333fred
Copy link
Copy Markdown
Member

333fred commented Aug 7, 2020

Done review pass (commit 24).

Copy link
Copy Markdown
Member

@333fred 333fred left a comment

Choose a reason for hiding this comment

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

LGTM (commit 29). @dotnet/roslyn-compiler for a second review.

case '!':
TextWindow.AdvanceChar();
if (TextWindow.PeekChar() == '=')
if (TextWindow.PeekChar() == '=' && TextWindow.PeekChar(-2) != '!')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Was a bit worried that this would cause a compat break but then remembered we do issue an error for this case:

var x = s!! = null;

Haven't gotten to the tests yet but if you didn't have to change a test like this we should write one to ensure it keeps failing after this change.

Copy link
Copy Markdown
Contributor Author

@kevinsun-dev kevinsun-dev Aug 10, 2020

Choose a reason for hiding this comment

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

Oh, that's no longer in there. I think that was from commit 17, and is gone now. It does break things and I had to change a bit of PeerChar that broke an invariant back then, but those have since been removed.

if (this.CurrentToken.Kind == SyntaxKind.ExclamationEqualsToken)
{
var exclamationEquals = this.EatToken();
var exclamation2 = SyntaxFactory.Token(exclamationEquals.GetLeadingTrivia(), SyntaxKind.ExclamationToken, null);
Copy link
Copy Markdown
Contributor

@cston cston Aug 10, 2020

Choose a reason for hiding this comment

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

exclamation2 [](start = 32, length = 12)

Consider renaming to "exclamation" since there's no "exclamation[1]'.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Might do that, or rename it to secondExclamation to emphasize that it's meant to be a part of the other Exclamation.


private SyntaxToken MergeTokens(SyntaxToken s1, SyntaxToken s2, SyntaxKind kind)
{
if (s1.GetTrailingTriviaWidth() == 0 && s2.GetLeadingTriviaWidth() == 0)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

s1.GetTrailingTriviaWidth() == 0 && s2.GetLeadingTriviaWidth() == 0 [](start = 16, length = 67)

Are we testing both cases where this fails? (When s1.GetTrailingTriviaWidth() > 0 and when s1.GetTrailingTriviaWidth() == 0 && s2.GetLeadingTriviaWidth() > 0?)

For instance:

static void F(object arg!
    != null);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Here are some of the cases covered:

    void M0(string name !!=null) { }
    void M1(string name! !=null) { }
    void M2(string name!!= null) { }
    void M3(string name ! !=null) { }
    void M4(string name ! ! =null) { }
    void M5(string name! ! =null) { }

}
else
{
s2 = this.AddError(s2, ErrorCode.ERR_InvalidExprTerm, this.CurrentToken.Text);
Copy link
Copy Markdown
Contributor

@cston cston Aug 10, 2020

Choose a reason for hiding this comment

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

this.CurrentToken.Text [](start = 70, length = 22)

Referencing this.CurrentToken seems surprising. Should this be s2 instead? #Closed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You're absolutely right, changed.

@@ -10896,9 +10904,10 @@ private bool ScanParenthesizedImplicitlyTypedLambda(Precedence precedence)
{
// allow for a) => or a!) =>
Copy link
Copy Markdown
Contributor

@cston cston Aug 10, 2020

Choose a reason for hiding this comment

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

a! [](start = 53, length = 2)

"a!!" #Closed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed, thanks!

if (exclamationExclamation != null)
{
exclamationExclamation = (exclamationExclamation.Kind != SyntaxKind.ExclamationExclamationToken)
? ConvertToMissingWithTrailingTrivia(exclamationExclamation, SyntaxKind.ExclamationExclamationToken)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ConvertToMissingWithTrailingTrivia(exclamationExclamation, SyntaxKind.ExclamationExclamationToken) [](start = 26, length = 98)

Should MergeTokens() be handling, rather than requiring each caller to do so?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the tip, I've modified MergeTokens to handle the conversion. Shouldn't have merged so early, it'll be in the next PR.


[Fact(Skip = "PROTOTYPE(BangBang)")]
[Fact]
public void TestOptParamMethodDeclarationWithNullValidationNoSpaces()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

TestOptParamMethodDeclarationWithNullValidationNoSpaces [](start = 20, length = 55)

Is this distinct from TestNullCheckedArgWithLeadingNewLine()?


[Fact(Skip = "PROTOTYPE(BangBang)")]
[Fact]
public void TestNullCheckedArgWithLeadingNewLine()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

TestNullCheckedArgWithLeadingNewLine [](start = 20, length = 36)

The name seems misleading since there aren't any newlines.


[Fact(Skip = "PROTOTYPE(BangBang)")]
[Fact]
public void TestNullCheckedArgWithLeadingSpace()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

TestNullCheckedArgWithLeadingSpace [](start = 20, length = 34)

Are the tokens in the following three tests distinct? If not, please consider merging into a single test method using `[Theory][InlineData("...")]...".


[Fact(Skip = "PROTOTYPE(BangBang)")]
[Fact]
public void TestNullCheckedArgWithSpaceAfterEquals()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

TestNullCheckedArgWithSpaceAfterEquals [](start = 20, length = 38)

Is this distinct from TestNullCheckedArgWithTrailingSpace()?

@kevinsun-dev kevinsun-dev merged commit 3b0b5e1 into dotnet:features/param-nullchecking Aug 11, 2020
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.

5 participants