Sum Type Field Access Fails Inside closure #23716
Labels
Bug
This tag is applied to issues which reports bugs.
Status: Confirmed
This bug has been confirmed to be valid by a contributor.
Unit: cgen
Bugs/feature requests, that are related to the default C generating backend.
Unit: Checker
Bugs/feature requests, that are related to the type checker.
Describe the bug
When using a sum type (Type = Aa | Bb) inside a function literal (fn[t]), the compiler fails to recognize the specific type variant of t and treats it as the general Type, rather than the matched variant (Aa).
Reproduction Steps
Expected Behavior
The expected behavior is that inside the function literal (
fn[t]
), the compiler should preserve the type information from the surrounding match branch. Since t is already matched asAa
, it should be treated as anAa
inside the function, allowing direct access tot.a
without requiring additional casting.Current Behavior
t
's type inside the closure is the sumtyp (Type
), and notAa
Possible Solution
No response
Additional Information/Context
No response
V version
V 0.4.9 5be2fca
Environment details (OS name and version, etc.)
Note
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.
The text was updated successfully, but these errors were encountered: