-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Do not parse methods with accessibility modifiers as local functions (alt) #74495
Do not parse methods with accessibility modifiers as local functions (alt) #74495
Conversation
…badi/roslyn into localFunctionVsMethod
Currently draft. But pulling @333fred in to get thoughts. |
{ | ||
internal abstract partial class TypeDeclarationSyntax | ||
{ | ||
public abstract TypeDeclarationSyntax UpdateCore( |
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.
Added as the internal syntax generator doesn't include these abstract/overrides in that model.
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.
i really don't ove this. but this mirrors how normal public syntax works. And, importantly, means that if we ever add a new type-decl subclass, we'll know we have to ensuer that thsi works.
It looks like some editor features tests are failing |
Both cases where hte new behavior in the presence of these error cases is fine :) |
@RikkiGibson this is ready for review. |
} | ||
"""; | ||
UsingTree(text, | ||
// (5,5): error CS1519: Invalid token '}' in class, record, struct, or interface member declaration |
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.
I am a little uneasy about this diagnostic. There is nothing wrong in itself with putting a }
here. The problem is that the }
is followed by a non-type/non-namespace member declaration.
I would be more comfortable with a diagnostic which blames the member private void M()
while implying that we didn't expect the preceding }
.
Something like: A namespace cannot directly contain members such as fields, methods or statements. Did you mean to include it as a member of type 'Type'?
(similar message to ERR_NamespaceUnexpected
)
It's possible that I just need to sit with it a bit and I'll come around. I'm not sure.
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.
this is fair. i'll think on it too and check in with you 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.
having thought about it, i'm ok with this error message. it is invalid. Now it happens to be invalid because of what we see later, btu i'm ok with that.
note: i'm not pushing back strongly. if you do want a specific error here, lmk.
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.
A namespace cannot directly contain members such as fields, methods or statements.
i'm not a fan of this primarily because the tree we produce won't jive with this. The node will appear inside the class from all other perspectives. But i do think we can clarify the error we put on the }
. Something like Errant '}' found between type members
. By saying 'between' we call out that there is another member tha tfollows.
Fixes #74482
Alternate to #74484
Also, makes the parser much better about errant close curly tokens causing type-members to now show up within a namespace, instead of in the preceding type-declaration.