You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Explicitly annotated unique symbols are widened in return positionsΒ #55361
getWidenedLiteralLikeTypeForContextualReturnTypeIfNeeded calls getWidenedLiteralLikeTypeForContextualType and that calls getWidenedUniqueESSymbolType when there is no contextual type provided.
This issue is actually different and I'm already fixing it here: #54778 π Different code paths handle widening from initializers and widening at return positions.
I'm not sure I'd call the existing behavior wrong, but it seems like a safe change to make
Are there any other cases in the compiler where an explicit type annotation like this gets stomped by the compiler and the type gets widened? I'm really curious about this. I assume that there is no place like this and that's why I'm calling this a bug. I also understand that symbols are somewhat special but as long as the symbol is publicly available (so the declaration emit can actually reference it) I think the annotation should be preserved.
Activity
fatcerberus commentedon Aug 14, 2023
I think you may have just found the underlying cause of #53276 π
Andarist commentedon Aug 14, 2023
This issue is actually different and I'm already fixing it here: #54778 π Different code paths handle widening from initializers and widening at return positions.
RyanCavanaugh commentedon Aug 15, 2023
I'm not sure I'd call the existing behavior wrong, but it seems like a safe change to make
ssalbdivad commentedon Aug 15, 2023
Ryan Cavanaugh (@RyanCavanaugh) Are there other situations where casting the only return statement of a function doesn't dictate how it's inferred?
Could even be simplified down to just:
Andarist commentedon Aug 15, 2023
Are there any other cases in the compiler where an explicit type annotation like this gets stomped by the compiler and the type gets widened? I'm really curious about this. I assume that there is no place like this and that's why I'm calling this a bug. I also understand that symbols are somewhat special but as long as the symbol is publicly available (so the declaration emit can actually reference it) I think the annotation should be preserved.