mirror of
https://github.com/dolthub/dolt.git
synced 2026-05-04 11:30:14 -05:00
Tweak the display of the type of an empty Map (#2590)
Fixes #2247 Closes #2252
This commit is contained in:
@@ -81,6 +81,6 @@ func (s *ThreeWaySetMergeSuite) TestThreeWayMerge_Refs() {
|
||||
}
|
||||
|
||||
func (s *ThreeWaySetMergeSuite) TestThreeWayMerge_ImmediateConflict() {
|
||||
s.tryThreeWayConflict(types.NewMap(), s.create(ss1b), s.create(ss1), "Cannot merge Map<, > with "+s.typeStr)
|
||||
s.tryThreeWayConflict(types.NewMap(), s.create(ss1b), s.create(ss1), "Cannot merge Map<> with "+s.typeStr)
|
||||
s.tryThreeWayConflict(s.create(ss1b), types.NewMap(), s.create(ss1), "Cannot merge "+s.typeStr)
|
||||
}
|
||||
|
||||
@@ -245,6 +245,11 @@ func (w *hrsWriter) writeType(t *Type, parentStructTypes []*Type) {
|
||||
w.write(KindToString[t.Kind()])
|
||||
w.write("<")
|
||||
for i, et := range t.Desc.(CompoundDesc).ElemTypes {
|
||||
if et.Kind() == UnionKind && len(et.Desc.(CompoundDesc).ElemTypes) == 0 {
|
||||
// If one of the element types is an empty union all the other element types must
|
||||
// also be empty union types.
|
||||
break
|
||||
}
|
||||
if i != 0 {
|
||||
w.write(", ")
|
||||
}
|
||||
|
||||
@@ -406,7 +406,7 @@ func TestEmptyCollections(t *testing.T) {
|
||||
c := MakeMapType(BlobType, NumberType)
|
||||
assertWriteTaggedHRSEqual(t, "Type(Map<Blob, Number>)", c)
|
||||
d := NewMap()
|
||||
assertWriteTaggedHRSEqual(t, "Map<, >({})", d)
|
||||
assertWriteTaggedHRSEqual(t, "Map<>({})", d)
|
||||
e := MakeSetType(StringType)
|
||||
assertWriteTaggedHRSEqual(t, "Type(Set<String>)", e)
|
||||
f := NewSet()
|
||||
|
||||
@@ -56,6 +56,8 @@ suite('Encode human readable types', () => {
|
||||
assertWriteType('', makeUnionType([]));
|
||||
assertWriteType('List<Number | String>', makeListType(makeUnionType([numberType, stringType])));
|
||||
assertWriteType('List<>', makeListType(makeUnionType([])));
|
||||
assertWriteType('Set<>', makeSetType(makeUnionType([])));
|
||||
assertWriteType('Map<>', makeMapType(makeUnionType([]), makeUnionType([])));
|
||||
});
|
||||
|
||||
test('struct', () => {
|
||||
|
||||
@@ -88,6 +88,11 @@ export class TypeWriter {
|
||||
this._w.write('<');
|
||||
invariant(t.desc instanceof CompoundDesc);
|
||||
t.desc.elemTypes.forEach((t, i) => {
|
||||
if (t.kind === Kind.Union && t.desc.elemTypes.length === 0) {
|
||||
// If one of the element types is an empty union all the other element types must also
|
||||
// be empty union types.
|
||||
return;
|
||||
}
|
||||
if (i !== 0) {
|
||||
this._w.write(', ');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user