(elems []super.Value)
| 113 | } |
| 114 | |
| 115 | func (d *defuse) unify(elems []super.Value) (super.Type, scode.Bytes) { |
| 116 | seen := make(map[super.Type]struct{}) |
| 117 | var types []super.Type |
| 118 | for _, e := range elems { |
| 119 | typ := e.Type() |
| 120 | if _, ok := seen[typ]; !ok { |
| 121 | seen[typ] = struct{}{} |
| 122 | types = append(types, typ) |
| 123 | } |
| 124 | } |
| 125 | if len(types) == 1 { |
| 126 | var b scode.Builder |
| 127 | for _, e := range elems { |
| 128 | b.Append(e.Bytes()) |
| 129 | } |
| 130 | return types[0], b.Bytes() |
| 131 | } |
| 132 | var b scode.Builder |
| 133 | union := d.sctx.LookupTypeUnion(types) |
| 134 | for _, e := range elems { |
| 135 | super.BuildUnion(&b, union.TagOf(e.Type()), e.Bytes()) |
| 136 | } |
| 137 | return union, b.Bytes() |
| 138 | } |
| 139 | |
| 140 | func (d *defuse) unifyType(vals []super.Value) super.Type { |
| 141 | seen := make(map[super.Type]struct{}) |
no test coverage detected