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

A syntax error is missing for a misplaced ColonColon token in explicit interface implementation. #53021

Closed
AlekseyTs opened this issue Apr 29, 2021 · 3 comments · Fixed by #55828
Assignees
Milestone

Comments

@AlekseyTs
Copy link
Contributor

using N = NS1;

public class C : NS1.I
{
    void N::I::M() // Expect an error on a :: before M
    {
    }
}

namespace NS1
{
    interface I
    {
        void M();
    }
}

Observed: No errors
Expected: A syntax error

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Issues and PRs which have not yet been triaged by a lead label Apr 29, 2021
@Youssef1313
Copy link
Member

Youssef1313 commented Apr 29, 2021

Fixing this bug would be a breaking change. Is the breaking change acceptable in this case? If it's acceptable, let me know and I can debug it.

With a quick look - I suspect the following condition should be moved up outside its containing if:

if (separator.Kind != SyntaxKind.DotToken)
{
separator = WithAdditionalDiagnostics(separator, GetExpectedTokenError(SyntaxKind.DotToken, separator.Kind, separator.GetLeadingTriviaWidth(), separator.Width));
separator = ConvertToMissingWithTrailingTrivia(separator, SyntaxKind.DotToken);
}

i.e, currently the above check doesn't flow in the following path:

explicitInterfaceOpt = _syntaxFactory.ExplicitInterfaceSpecifier(explicitInterfaceName, separator);

(Not much confident without debugging it)

@AlekseyTs
Copy link
Contributor Author

I think the fix is actually to report ERR_AliasQualAsExpression here

? this.ConvertToMissingWithTrailingTrivia(this.EatToken(), SyntaxKind.DotToken)
as we do here
separator = this.AddError(separator, ErrorCode.ERR_AliasQualAsExpression);
.

@AlekseyTs
Copy link
Contributor Author

However, it looks like ERR_UnexpectedAliasedName would be more appropriate for the N1::N2::I.M scenario.

@jaredpar jaredpar removed the untriaged Issues and PRs which have not yet been triaged by a lead label Jul 13, 2021
@jaredpar jaredpar added this to the 17.0 milestone Jul 13, 2021
AlekseyTs added a commit that referenced this issue Aug 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants