Skip to content

Conversation

@333fred
Copy link
Member

@333fred 333fred commented Nov 19, 2019

@333fred 333fred requested review from a team and AlekseyTs November 19, 2019 02:06
@CyrusNajmabadi
Copy link
Member

CyrusNajmabadi commented Nov 19, 2019

LGTM. However, there are several things i think can/should be done to make the parser more production-ready for the types of cases we should expect users to be running into. In general, this means not overfitting the syntax model, and it means detecting and being resilient to expected user mistakes. #Resolved

Copy link
Member

@gafter gafter left a comment

Choose a reason for hiding this comment

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

A couple of comments inline. To summarize:

  1. Probably check for < as part of knowing we have a function type in IsFunctionPointerStart
  2. ScanFunctionPointerType should say not a type if the structure is wrong (i.e. no <)

Copy link
Member

@CyrusNajmabadi CyrusNajmabadi left a comment

Choose a reason for hiding this comment

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

c

@333fred
Copy link
Member Author

333fred commented Nov 20, 2019

Pushed an updated that addressed a lot of feedback. There will still be a test failure as I haven't updated the AllInOneCSharp file, I will do this later. #Resolved

…s will be a semantic error, rather than a syntax error.
@333fred 333fred requested a review from a team as a code owner November 20, 2019 23:55
@AlekseyTs
Copy link
Contributor

AlekseyTs commented Nov 22, 2019

Done with review pass (iteration 4) #Closed

@333fred
Copy link
Member Author

333fred commented Nov 22, 2019

@AlekseyTs addressed feedback, thanks!


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

Copy link
Contributor

@sharwell sharwell left a comment

Choose a reason for hiding this comment

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

IDE change (trivial change in features layer) is fine

@AlekseyTs
Copy link
Contributor

AlekseyTs commented Nov 25, 2019

Done with review pass (iteration 5) #Closed

@333fred
Copy link
Member Author

333fred commented Nov 26, 2019

@AlekseyTs addressed feedback.


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

// we'd have an error anyway, and it's more likely the user intended for it to be a
// function pointer convention than not.
// PROTOTYPE(func-ptr): refactor this out into a helper method to share with binding
switch (CurrentToken.ValueText)
Copy link
Contributor

@AlekseyTs AlekseyTs Nov 26, 2019

Choose a reason for hiding this comment

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

CurrentToken.ValueText [](start = 20, length = 22)

I think this change should be backed by a test that observes the difference in behavior.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this change should be backed by a test that observes the difference in behavior.

After adding a test, I've gone back to Text instead of ValueText, as we don't want to treat @cdecl as a calling convention, given that it's been escaped.


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

Copy link
Contributor

Choose a reason for hiding this comment

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

After adding a test, I've gone back to Text instead of ValueText, as we don't want to treat @cdecl as a calling convention, given that it's been escaped.

It feels like we are somewhat inconsistent:

  • delegate* @cdecl - return false
  • delegate* @cdecl < - return true

Perhaps we should ignore all escaped identifiers? I think it would be fine to add a prototype comment and follow up on this later.


In reply to: 350976752 [](ancestors = 350976752,350896749)

Copy link
Member Author

Choose a reason for hiding this comment

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

It feels like we are somewhat inconsistent

I don't think that that's any more inconsistent than a non-escaped regular identifier that isn't a known convention, like MyType. We special case things that we know are valid calling conventions, but the convention was specifically escaped here so we treat it as any other invalid identifier.


In reply to: 351425780 [](ancestors = 351425780,350976752,350896749)

Copy link
Contributor

@AlekseyTs AlekseyTs Nov 27, 2019

Choose a reason for hiding this comment

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

I don't think that that's any more inconsistent than a non-escaped regular identifier that isn't a known convention, like MyType. We special case things that we know are valid calling conventions, but the convention was specifically escaped here so we treat it as any other invalid identifier.

Then why do we treat @cdecl as possibly valid calling convention when it is followed by <. If grammar doesn't allow escaped identifiers, then we should not accept them.


In reply to: 351441102 [](ancestors = 351441102,351425780,350976752,350896749)

Copy link
Contributor

@AlekseyTs AlekseyTs left a comment

Choose a reason for hiding this comment

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

LGTM (iteration 6) modulo the test suggestion.

Copy link
Member

@gafter gafter left a comment

Choose a reason for hiding this comment

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

:shipit:

@AlekseyTs
Copy link
Contributor

AlekseyTs commented Nov 27, 2019

        UsingStatement("delegate* @cdecl>", options: TestOptions.RegularPreview,

Consider adding a test for delegate* @cdecl < ...


Refers to: src/Compilers/CSharp/Test/Syntax/Parsing/FunctionPointerTests.cs:815 in 27e8523. [](commit_id = 27e8523, deletion_comment = False)

Copy link
Contributor

@AlekseyTs AlekseyTs left a comment

Choose a reason for hiding this comment

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

LGTM (iteration 7).

@333fred
Copy link
Member Author

333fred commented Nov 27, 2019

        UsingStatement("delegate* @cdecl>", options: TestOptions.RegularPreview,

That's in my plan for binding tests, but it's not particularly interesting on a syntax level because it's just like any other invalid calling convention.


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


Refers to: src/Compilers/CSharp/Test/Syntax/Parsing/FunctionPointerTests.cs:815 in 3231dcc. [](commit_id = 3231dcc, deletion_comment = False)

@333fred 333fred merged commit 4be5cd6 into dotnet:features/function-pointers Nov 27, 2019
@333fred 333fred deleted the parsing branch November 27, 2019 18:34
@AlekseyTs
Copy link
Contributor

        UsingStatement("delegate* @cdecl>", options: TestOptions.RegularPreview,

but it's not particularly interesting on a syntax level because it's just like any other invalid calling convention.

I find the suggested scenario interesting from the parsing point of view because of the contrast to the behavior with scenario in this test. Please consider adding one.


In reply to: 559204507 [](ancestors = 559204507,559191659)


Refers to: src/Compilers/CSharp/Test/Syntax/Parsing/FunctionPointerTests.cs:815 in 27e8523. [](commit_id = 27e8523, deletion_comment = False)

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