Skip to content

Compiler should provide a better error message for generic type constraint 'enum' #59495

@sharwell

Description

@sharwell

Version Used: 4.2.0-1.22104.1 (8d81aa5)

Steps to Reproduce:

public void Method<TEnum>(TEnum command)
    where TEnum : enum
{
}

Expected Behavior:

  1. A specific error message is reported on the enum token
  2. The compiler recovers from the error with a reasonable parse tree

Actual Behavior:

  1. CS1031 (Type expected) is reported
  2. Many subsequent parse errors are reported

Metadata

Metadata

Assignees

Labels

4 - In ReviewA fix for the issue is submitted for review.Area-CompilersConcept-Diagnostic ClarityThe issues deals with the ease of understanding of errors and warnings.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions