diff --git a/src/cmd/compile/internal/types2/termlist.go b/src/cmd/compile/internal/types2/termlist.go index a0108c46383..43e43ce87c7 100644 --- a/src/cmd/compile/internal/types2/termlist.go +++ b/src/cmd/compile/internal/types2/termlist.go @@ -25,7 +25,7 @@ func (xl termlist) String() string { var buf bytes.Buffer for i, x := range xl { if i > 0 { - buf.WriteString(" ∪ ") + buf.WriteString(" | ") } buf.WriteString(x.String()) } diff --git a/src/cmd/compile/internal/types2/termlist_test.go b/src/cmd/compile/internal/types2/termlist_test.go index d1e3bdf88ef..3005d0edea0 100644 --- a/src/cmd/compile/internal/types2/termlist_test.go +++ b/src/cmd/compile/internal/types2/termlist_test.go @@ -12,7 +12,7 @@ import ( // maketl makes a term list from a string of the term list. func maketl(s string) termlist { s = strings.ReplaceAll(s, " ", "") - names := strings.Split(s, "∪") + names := strings.Split(s, "|") r := make(termlist, len(names)) for i, n := range names { r[i] = testTerm(n) @@ -33,10 +33,10 @@ func TestTermlistString(t *testing.T) { "int", "~int", "myInt", - "∅ ∪ ∅", - "𝓤 ∪ 𝓤", - "∅ ∪ 𝓤 ∪ int", - "∅ ∪ 𝓤 ∪ int ∪ myInt", + "∅ | ∅", + "𝓤 | 𝓤", + "∅ | 𝓤 | int", + "∅ | 𝓤 | int | myInt", } { if got := maketl(want).String(); got != want { t.Errorf("(%v).String() == %v", want, got) @@ -47,12 +47,12 @@ func TestTermlistString(t *testing.T) { func TestTermlistIsEmpty(t *testing.T) { for test, want := range map[string]bool{ "∅": true, - "∅ ∪ ∅": true, - "∅ ∪ ∅ ∪ 𝓤": false, - "∅ ∪ ∅ ∪ myInt": false, + "∅ | ∅": true, + "∅ | ∅ | 𝓤": false, + "∅ | ∅ | myInt": false, "𝓤": false, - "𝓤 ∪ int": false, - "𝓤 ∪ myInt ∪ ∅": false, + "𝓤 | int": false, + "𝓤 | myInt | ∅": false, } { xl := maketl(test) got := xl.isEmpty() @@ -65,13 +65,13 @@ func TestTermlistIsEmpty(t *testing.T) { func TestTermlistIsAll(t *testing.T) { for test, want := range map[string]bool{ "∅": false, - "∅ ∪ ∅": false, - "int ∪ ~string": false, - "~int ∪ myInt": false, - "∅ ∪ ∅ ∪ 𝓤": true, + "∅ | ∅": false, + "int | ~string": false, + "~int | myInt": false, + "∅ | ∅ | 𝓤": true, "𝓤": true, - "𝓤 ∪ int": true, - "myInt ∪ 𝓤": true, + "𝓤 | int": true, + "myInt | 𝓤": true, } { xl := maketl(test) got := xl.isAll() @@ -86,17 +86,17 @@ func TestTermlistNorm(t *testing.T) { xl, want string }{ {"∅", "∅"}, - {"∅ ∪ ∅", "∅"}, - {"∅ ∪ int", "int"}, - {"∅ ∪ myInt", "myInt"}, - {"𝓤 ∪ int", "𝓤"}, - {"𝓤 ∪ myInt", "𝓤"}, - {"int ∪ myInt", "int ∪ myInt"}, - {"~int ∪ int", "~int"}, - {"~int ∪ myInt", "~int"}, - {"int ∪ ~string ∪ int", "int ∪ ~string"}, - {"~int ∪ string ∪ 𝓤 ∪ ~string ∪ int", "𝓤"}, - {"~int ∪ string ∪ myInt ∪ ~string ∪ int", "~int ∪ ~string"}, + {"∅ | ∅", "∅"}, + {"∅ | int", "int"}, + {"∅ | myInt", "myInt"}, + {"𝓤 | int", "𝓤"}, + {"𝓤 | myInt", "𝓤"}, + {"int | myInt", "int | myInt"}, + {"~int | int", "~int"}, + {"~int | myInt", "~int"}, + {"int | ~string | int", "int | ~string"}, + {"~int | string | 𝓤 | ~string | int", "𝓤"}, + {"~int | string | myInt | ~string | int", "~int | ~string"}, } { xl := maketl(test.xl) got := maketl(test.xl).norm() @@ -116,15 +116,15 @@ func TestTermlistUnion(t *testing.T) { {"∅", "int", "int"}, {"𝓤", "~int", "𝓤"}, {"int", "~int", "~int"}, - {"int", "string", "int ∪ string"}, - {"int", "myInt", "int ∪ myInt"}, + {"int", "string", "int | string"}, + {"int", "myInt", "int | myInt"}, {"~int", "myInt", "~int"}, - {"int ∪ string", "~string", "int ∪ ~string"}, - {"~int ∪ string", "~string ∪ int", "~int ∪ ~string"}, - {"~int ∪ string ∪ ∅", "~string ∪ int", "~int ∪ ~string"}, - {"~int ∪ myInt ∪ ∅", "~string ∪ int", "~int ∪ ~string"}, - {"~int ∪ string ∪ 𝓤", "~string ∪ int", "𝓤"}, - {"~int ∪ string ∪ myInt", "~string ∪ int", "~int ∪ ~string"}, + {"int | string", "~string", "int | ~string"}, + {"~int | string", "~string | int", "~int | ~string"}, + {"~int | string | ∅", "~string | int", "~int | ~string"}, + {"~int | myInt | ∅", "~string | int", "~int | ~string"}, + {"~int | string | 𝓤", "~string | int", "𝓤"}, + {"~int | string | myInt", "~string | int", "~int | ~string"}, } { xl := maketl(test.xl) yl := maketl(test.yl) @@ -150,12 +150,12 @@ func TestTermlistIntersect(t *testing.T) { {"int", "string", "∅"}, {"int", "myInt", "∅"}, {"~int", "myInt", "myInt"}, - {"int ∪ string", "~string", "string"}, - {"~int ∪ string", "~string ∪ int", "int ∪ string"}, - {"~int ∪ string ∪ ∅", "~string ∪ int", "int ∪ string"}, - {"~int ∪ myInt ∪ ∅", "~string ∪ int", "int"}, - {"~int ∪ string ∪ 𝓤", "~string ∪ int", "int ∪ ~string"}, - {"~int ∪ string ∪ myInt", "~string ∪ int", "int ∪ string"}, + {"int | string", "~string", "string"}, + {"~int | string", "~string | int", "int | string"}, + {"~int | string | ∅", "~string | int", "int | string"}, + {"~int | myInt | ∅", "~string | int", "int"}, + {"~int | string | 𝓤", "~string | int", "int | ~string"}, + {"~int | string | myInt", "~string | int", "int | string"}, } { xl := maketl(test.xl) yl := maketl(test.yl) @@ -174,12 +174,12 @@ func TestTermlistEqual(t *testing.T) { {"∅", "∅", true}, {"∅", "𝓤", false}, {"𝓤", "𝓤", true}, - {"𝓤 ∪ int", "𝓤", true}, - {"𝓤 ∪ int", "string ∪ 𝓤", true}, - {"𝓤 ∪ myInt", "string ∪ 𝓤", true}, - {"int ∪ ~string", "string ∪ int", false}, - {"~int ∪ string", "string ∪ myInt", false}, - {"int ∪ ~string ∪ ∅", "string ∪ int ∪ ~string", true}, + {"𝓤 | int", "𝓤", true}, + {"𝓤 | int", "string | 𝓤", true}, + {"𝓤 | myInt", "string | 𝓤", true}, + {"int | ~string", "string | int", false}, + {"~int | string", "string | myInt", false}, + {"int | ~string | ∅", "string | int | ~string", true}, } { xl := maketl(test.xl) yl := maketl(test.yl) @@ -201,11 +201,11 @@ func TestTermlistIncludes(t *testing.T) { {"int", "string", false}, {"~int", "string", false}, {"~int", "myInt", true}, - {"int ∪ string", "string", true}, - {"~int ∪ string", "int", true}, - {"~int ∪ string", "myInt", true}, - {"~int ∪ myInt ∪ ∅", "myInt", true}, - {"myInt ∪ ∅ ∪ 𝓤", "int", true}, + {"int | string", "string", true}, + {"~int | string", "int", true}, + {"~int | string", "myInt", true}, + {"~int | myInt | ∅", "myInt", true}, + {"myInt | ∅ | 𝓤", "int", true}, } { xl := maketl(test.xl) yl := testTerm(test.typ).typ @@ -236,12 +236,12 @@ func TestTermlistSupersetOf(t *testing.T) { {"myInt", "~int", false}, {"int", "string", false}, {"~int", "string", false}, - {"int ∪ string", "string", true}, - {"int ∪ string", "~string", false}, - {"~int ∪ string", "int", true}, - {"~int ∪ string", "myInt", true}, - {"~int ∪ string ∪ ∅", "string", true}, - {"~string ∪ ∅ ∪ 𝓤", "myInt", true}, + {"int | string", "string", true}, + {"int | string", "~string", false}, + {"~int | string", "int", true}, + {"~int | string", "myInt", true}, + {"~int | string | ∅", "string", true}, + {"~string | ∅ | 𝓤", "myInt", true}, } { xl := maketl(test.xl) y := testTerm(test.typ) @@ -261,18 +261,18 @@ func TestTermlistSubsetOf(t *testing.T) { {"∅", "𝓤", true}, {"𝓤", "∅", false}, {"𝓤", "𝓤", true}, - {"int", "int ∪ string", true}, - {"~int", "int ∪ string", false}, - {"~int", "myInt ∪ string", false}, - {"myInt", "~int ∪ string", true}, - {"~int", "string ∪ string ∪ int ∪ ~int", true}, - {"myInt", "string ∪ string ∪ ~int", true}, - {"int ∪ string", "string", false}, - {"int ∪ string", "string ∪ int", true}, - {"int ∪ ~string", "string ∪ int", false}, - {"myInt ∪ ~string", "string ∪ int ∪ 𝓤", true}, - {"int ∪ ~string", "string ∪ int ∪ ∅ ∪ string", false}, - {"int ∪ myInt", "string ∪ ~int ∪ ∅ ∪ string", true}, + {"int", "int | string", true}, + {"~int", "int | string", false}, + {"~int", "myInt | string", false}, + {"myInt", "~int | string", true}, + {"~int", "string | string | int | ~int", true}, + {"myInt", "string | string | ~int", true}, + {"int | string", "string", false}, + {"int | string", "string | int", true}, + {"int | ~string", "string | int", false}, + {"myInt | ~string", "string | int | 𝓤", true}, + {"int | ~string", "string | int | ∅ | string", false}, + {"int | myInt", "string | ~int | ∅ | string", true}, } { xl := maketl(test.xl) yl := maketl(test.yl) diff --git a/src/cmd/compile/internal/types2/typeset_test.go b/src/cmd/compile/internal/types2/typeset_test.go index 69eaff741fc..40ca28e525f 100644 --- a/src/cmd/compile/internal/types2/typeset_test.go +++ b/src/cmd/compile/internal/types2/typeset_test.go @@ -21,13 +21,13 @@ func TestTypeSetString(t *testing.T) { "{}": "𝓤", "{int}": "{int}", "{~int}": "{~int}", - "{int|string}": "{int ∪ string}", + "{int|string}": "{int | string}", "{int; string}": "∅", "{comparable}": "{comparable}", "{comparable; int}": "{int}", "{~int; comparable}": "{~int}", - "{int|string; comparable}": "{int ∪ string}", + "{int|string; comparable}": "{int | string}", "{comparable; int; string}": "∅", "{m()}": "{func (p.T).m()}", @@ -37,7 +37,7 @@ func TestTypeSetString(t *testing.T) { "{m1(); comparable; m2() int }": "{comparable; func (p.T).m1(); func (p.T).m2() int}", "{comparable; error}": "{comparable; func (error).Error() string}", - "{m(); comparable; int|float32|string}": "{func (p.T).m(); int ∪ float32 ∪ string}", + "{m(); comparable; int|float32|string}": "{func (p.T).m(); int | float32 | string}", "{m1(); int; m2(); comparable }": "{func (p.T).m1(); func (p.T).m2(); int}", "{E}; type E interface{}": "𝓤", diff --git a/src/go/types/termlist.go b/src/go/types/termlist.go index 94e49caee04..6d08ddb397a 100644 --- a/src/go/types/termlist.go +++ b/src/go/types/termlist.go @@ -25,7 +25,7 @@ func (xl termlist) String() string { var buf bytes.Buffer for i, x := range xl { if i > 0 { - buf.WriteString(" ∪ ") + buf.WriteString(" | ") } buf.WriteString(x.String()) } diff --git a/src/go/types/termlist_test.go b/src/go/types/termlist_test.go index f0d58ac1bcf..0ff687ebda6 100644 --- a/src/go/types/termlist_test.go +++ b/src/go/types/termlist_test.go @@ -12,7 +12,7 @@ import ( // maketl makes a term list from a string of the term list. func maketl(s string) termlist { s = strings.ReplaceAll(s, " ", "") - names := strings.Split(s, "∪") + names := strings.Split(s, "|") r := make(termlist, len(names)) for i, n := range names { r[i] = testTerm(n) @@ -33,10 +33,10 @@ func TestTermlistString(t *testing.T) { "int", "~int", "myInt", - "∅ ∪ ∅", - "𝓤 ∪ 𝓤", - "∅ ∪ 𝓤 ∪ int", - "∅ ∪ 𝓤 ∪ int ∪ myInt", + "∅ | ∅", + "𝓤 | 𝓤", + "∅ | 𝓤 | int", + "∅ | 𝓤 | int | myInt", } { if got := maketl(want).String(); got != want { t.Errorf("(%v).String() == %v", want, got) @@ -47,12 +47,12 @@ func TestTermlistString(t *testing.T) { func TestTermlistIsEmpty(t *testing.T) { for test, want := range map[string]bool{ "∅": true, - "∅ ∪ ∅": true, - "∅ ∪ ∅ ∪ 𝓤": false, - "∅ ∪ ∅ ∪ myInt": false, + "∅ | ∅": true, + "∅ | ∅ | 𝓤": false, + "∅ | ∅ | myInt": false, "𝓤": false, - "𝓤 ∪ int": false, - "𝓤 ∪ myInt ∪ ∅": false, + "𝓤 | int": false, + "𝓤 | myInt | ∅": false, } { xl := maketl(test) got := xl.isEmpty() @@ -65,13 +65,13 @@ func TestTermlistIsEmpty(t *testing.T) { func TestTermlistIsAll(t *testing.T) { for test, want := range map[string]bool{ "∅": false, - "∅ ∪ ∅": false, - "int ∪ ~string": false, - "~int ∪ myInt": false, - "∅ ∪ ∅ ∪ 𝓤": true, + "∅ | ∅": false, + "int | ~string": false, + "~int | myInt": false, + "∅ | ∅ | 𝓤": true, "𝓤": true, - "𝓤 ∪ int": true, - "myInt ∪ 𝓤": true, + "𝓤 | int": true, + "myInt | 𝓤": true, } { xl := maketl(test) got := xl.isAll() @@ -86,17 +86,17 @@ func TestTermlistNorm(t *testing.T) { xl, want string }{ {"∅", "∅"}, - {"∅ ∪ ∅", "∅"}, - {"∅ ∪ int", "int"}, - {"∅ ∪ myInt", "myInt"}, - {"𝓤 ∪ int", "𝓤"}, - {"𝓤 ∪ myInt", "𝓤"}, - {"int ∪ myInt", "int ∪ myInt"}, - {"~int ∪ int", "~int"}, - {"~int ∪ myInt", "~int"}, - {"int ∪ ~string ∪ int", "int ∪ ~string"}, - {"~int ∪ string ∪ 𝓤 ∪ ~string ∪ int", "𝓤"}, - {"~int ∪ string ∪ myInt ∪ ~string ∪ int", "~int ∪ ~string"}, + {"∅ | ∅", "∅"}, + {"∅ | int", "int"}, + {"∅ | myInt", "myInt"}, + {"𝓤 | int", "𝓤"}, + {"𝓤 | myInt", "𝓤"}, + {"int | myInt", "int | myInt"}, + {"~int | int", "~int"}, + {"~int | myInt", "~int"}, + {"int | ~string | int", "int | ~string"}, + {"~int | string | 𝓤 | ~string | int", "𝓤"}, + {"~int | string | myInt | ~string | int", "~int | ~string"}, } { xl := maketl(test.xl) got := maketl(test.xl).norm() @@ -116,15 +116,15 @@ func TestTermlistUnion(t *testing.T) { {"∅", "int", "int"}, {"𝓤", "~int", "𝓤"}, {"int", "~int", "~int"}, - {"int", "string", "int ∪ string"}, - {"int", "myInt", "int ∪ myInt"}, + {"int", "string", "int | string"}, + {"int", "myInt", "int | myInt"}, {"~int", "myInt", "~int"}, - {"int ∪ string", "~string", "int ∪ ~string"}, - {"~int ∪ string", "~string ∪ int", "~int ∪ ~string"}, - {"~int ∪ string ∪ ∅", "~string ∪ int", "~int ∪ ~string"}, - {"~int ∪ myInt ∪ ∅", "~string ∪ int", "~int ∪ ~string"}, - {"~int ∪ string ∪ 𝓤", "~string ∪ int", "𝓤"}, - {"~int ∪ string ∪ myInt", "~string ∪ int", "~int ∪ ~string"}, + {"int | string", "~string", "int | ~string"}, + {"~int | string", "~string | int", "~int | ~string"}, + {"~int | string | ∅", "~string | int", "~int | ~string"}, + {"~int | myInt | ∅", "~string | int", "~int | ~string"}, + {"~int | string | 𝓤", "~string | int", "𝓤"}, + {"~int | string | myInt", "~string | int", "~int | ~string"}, } { xl := maketl(test.xl) yl := maketl(test.yl) @@ -150,12 +150,12 @@ func TestTermlistIntersect(t *testing.T) { {"int", "string", "∅"}, {"int", "myInt", "∅"}, {"~int", "myInt", "myInt"}, - {"int ∪ string", "~string", "string"}, - {"~int ∪ string", "~string ∪ int", "int ∪ string"}, - {"~int ∪ string ∪ ∅", "~string ∪ int", "int ∪ string"}, - {"~int ∪ myInt ∪ ∅", "~string ∪ int", "int"}, - {"~int ∪ string ∪ 𝓤", "~string ∪ int", "int ∪ ~string"}, - {"~int ∪ string ∪ myInt", "~string ∪ int", "int ∪ string"}, + {"int | string", "~string", "string"}, + {"~int | string", "~string | int", "int | string"}, + {"~int | string | ∅", "~string | int", "int | string"}, + {"~int | myInt | ∅", "~string | int", "int"}, + {"~int | string | 𝓤", "~string | int", "int | ~string"}, + {"~int | string | myInt", "~string | int", "int | string"}, } { xl := maketl(test.xl) yl := maketl(test.yl) @@ -174,12 +174,12 @@ func TestTermlistEqual(t *testing.T) { {"∅", "∅", true}, {"∅", "𝓤", false}, {"𝓤", "𝓤", true}, - {"𝓤 ∪ int", "𝓤", true}, - {"𝓤 ∪ int", "string ∪ 𝓤", true}, - {"𝓤 ∪ myInt", "string ∪ 𝓤", true}, - {"int ∪ ~string", "string ∪ int", false}, - {"~int ∪ string", "string ∪ myInt", false}, - {"int ∪ ~string ∪ ∅", "string ∪ int ∪ ~string", true}, + {"𝓤 | int", "𝓤", true}, + {"𝓤 | int", "string | 𝓤", true}, + {"𝓤 | myInt", "string | 𝓤", true}, + {"int | ~string", "string | int", false}, + {"~int | string", "string | myInt", false}, + {"int | ~string | ∅", "string | int | ~string", true}, } { xl := maketl(test.xl) yl := maketl(test.yl) @@ -201,11 +201,11 @@ func TestTermlistIncludes(t *testing.T) { {"int", "string", false}, {"~int", "string", false}, {"~int", "myInt", true}, - {"int ∪ string", "string", true}, - {"~int ∪ string", "int", true}, - {"~int ∪ string", "myInt", true}, - {"~int ∪ myInt ∪ ∅", "myInt", true}, - {"myInt ∪ ∅ ∪ 𝓤", "int", true}, + {"int | string", "string", true}, + {"~int | string", "int", true}, + {"~int | string", "myInt", true}, + {"~int | myInt | ∅", "myInt", true}, + {"myInt | ∅ | 𝓤", "int", true}, } { xl := maketl(test.xl) yl := testTerm(test.typ).typ @@ -236,12 +236,12 @@ func TestTermlistSupersetOf(t *testing.T) { {"myInt", "~int", false}, {"int", "string", false}, {"~int", "string", false}, - {"int ∪ string", "string", true}, - {"int ∪ string", "~string", false}, - {"~int ∪ string", "int", true}, - {"~int ∪ string", "myInt", true}, - {"~int ∪ string ∪ ∅", "string", true}, - {"~string ∪ ∅ ∪ 𝓤", "myInt", true}, + {"int | string", "string", true}, + {"int | string", "~string", false}, + {"~int | string", "int", true}, + {"~int | string", "myInt", true}, + {"~int | string | ∅", "string", true}, + {"~string | ∅ | 𝓤", "myInt", true}, } { xl := maketl(test.xl) y := testTerm(test.typ) @@ -261,18 +261,18 @@ func TestTermlistSubsetOf(t *testing.T) { {"∅", "𝓤", true}, {"𝓤", "∅", false}, {"𝓤", "𝓤", true}, - {"int", "int ∪ string", true}, - {"~int", "int ∪ string", false}, - {"~int", "myInt ∪ string", false}, - {"myInt", "~int ∪ string", true}, - {"~int", "string ∪ string ∪ int ∪ ~int", true}, - {"myInt", "string ∪ string ∪ ~int", true}, - {"int ∪ string", "string", false}, - {"int ∪ string", "string ∪ int", true}, - {"int ∪ ~string", "string ∪ int", false}, - {"myInt ∪ ~string", "string ∪ int ∪ 𝓤", true}, - {"int ∪ ~string", "string ∪ int ∪ ∅ ∪ string", false}, - {"int ∪ myInt", "string ∪ ~int ∪ ∅ ∪ string", true}, + {"int", "int | string", true}, + {"~int", "int | string", false}, + {"~int", "myInt | string", false}, + {"myInt", "~int | string", true}, + {"~int", "string | string | int | ~int", true}, + {"myInt", "string | string | ~int", true}, + {"int | string", "string", false}, + {"int | string", "string | int", true}, + {"int | ~string", "string | int", false}, + {"myInt | ~string", "string | int | 𝓤", true}, + {"int | ~string", "string | int | ∅ | string", false}, + {"int | myInt", "string | ~int | ∅ | string", true}, } { xl := maketl(test.xl) yl := maketl(test.yl) diff --git a/src/go/types/typeset_test.go b/src/go/types/typeset_test.go index 2bbe6113760..51560924839 100644 --- a/src/go/types/typeset_test.go +++ b/src/go/types/typeset_test.go @@ -22,13 +22,13 @@ func TestTypeSetString(t *testing.T) { "{}": "𝓤", "{int}": "{int}", "{~int}": "{~int}", - "{int|string}": "{int ∪ string}", + "{int|string}": "{int | string}", "{int; string}": "∅", "{comparable}": "{comparable}", "{comparable; int}": "{int}", "{~int; comparable}": "{~int}", - "{int|string; comparable}": "{int ∪ string}", + "{int|string; comparable}": "{int | string}", "{comparable; int; string}": "∅", "{m()}": "{func (p.T).m()}", @@ -38,7 +38,7 @@ func TestTypeSetString(t *testing.T) { "{m1(); comparable; m2() int }": "{comparable; func (p.T).m1(); func (p.T).m2() int}", "{comparable; error}": "{comparable; func (error).Error() string}", - "{m(); comparable; int|float32|string}": "{func (p.T).m(); int ∪ float32 ∪ string}", + "{m(); comparable; int|float32|string}": "{func (p.T).m(); int | float32 | string}", "{m1(); int; m2(); comparable }": "{func (p.T).m1(); func (p.T).m2(); int}", "{E}; type E interface{}": "𝓤",