-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Error using associated constant in return type of generic function #56605
Copy link
Copy link
Open
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team
Metadata
Metadata
Assignees
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team
Type
Fields
Give feedbackNo fields configured for issues without a type.
Consider the following code:
The compiler will error with:
Now there is a clear constraint on T, meaning that LEN should be valid. I'm guessing the return type is being evaluated before the constraint, whereas it should check after, at which point it would know this this ought to be valid.
Tested in 1.31 stable and 1.32 nightly (Dec 7 2018)