When one variant of a two-variant enum is narrowed out via control flow both prior to an indefinite loop, attempts to save the narrowed variable to another local result in a circularity error #48849
Labels
Duplicate
An existing issue was already created
Bug Report
🔎 Search Terms
Just searched the error message noted below.
Possibly related:
🕗 Version & Regression Information
💻 Code
Output
Compiler Options
Playground Link: Provided
🙁 Actual behavior
current
intest1
andtest2
fail with "'current' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. (7022)"current
in the rest are all resolved toState.One
🙂 Expected behavior
current
in all examples to be resolved to theState.One
state
in all examples to fail, asnumber
is not assignable to the enumState
It's worth noting that Intellisense picks up that
state
is contextuallyState.One
in the RHS ofconst current = state
in all 5 examples. My suspicion isstate
's narrowed type just isn't being propagated tocurrent
, or at least the false circularity prevents it from being propagated - manually specifying the narrowed type does in fact work.The text was updated successfully, but these errors were encountered: