MCPcopy Index your code
hub / github.com/MadAppGang/dingo / isTupleVariant

Method isTupleVariant

pkg/codegen/match.go:760–770  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

758// TODO: This should lookup variant metadata from a type registry
759// instead of hard-coding known types.
760func (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 }

Calls

no outgoing calls

Tested by

no test coverage detected