isTupleVariant determines if a type name represents a tuple variant. Tuple variants use positional fields (Value, Value0, Value1, ...). Struct variants use named fields matching the struct definition. Currently handles: - Result variants: ResultOk, ResultErr (tuple) - Option variants: OptionSome, O
(typeName string)
| 758 | // TODO: This should lookup variant metadata from a type registry |
| 759 | // instead of hard-coding known types. |
| 760 | func (g *MatchCodeGen) isTupleVariant(typeName string) bool { |
| 761 | // Result and Option built-in types use tuple variants |
| 762 | switch typeName { |
| 763 | case "ResultOk", "ResultErr", "OptionSome", "OptionNone": |
| 764 | return true |
| 765 | } |
| 766 | |
| 767 | // Custom enums currently assumed to be struct variants |
| 768 | // This will be fixed when we have a proper type registry (see action items #5) |
| 769 | return false |
| 770 | } |
| 771 | |
| 772 | // generateHumanLikeAssignment generates code for assignment context (x := match ...). |
| 773 | // Produces: var x TYPE; switch { case ...: x = value } |
no outgoing calls
no test coverage detected