Enum associated functions can name-clash with variants, but cannot be called. #39946
Labels
A-lint
Area: Lints (warnings about flaws in source code) such as unused_mut.
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Description
It's currently possible to name a function associated to an enum identically to the name of one of its variants.
This function cannot be called (see below), but rather than warning at the point that the function is defined, the compiler only emits an error upon trying to call said function (and in some cases - see the 'Alternate Reproduction' - it doesn't even do that).
https://is.gd/EZQ9mL
yields:
Expected behaviour:
Emit an error at the point (
fn a() -> X
) that the function is defined.Alternate reproduction
Even more confusing is the code:
https://is.gd/S15gOw
This compiles and runs.
Any guesses whether the variant or the function wins? 😄
The text was updated successfully, but these errors were encountered: