forked from gopherjs/gopherjs
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Yield explicit errors when encountering typeparams.
Even though the compiler was usually able to compile them into _something_, the code was likely incorrect in all cases. To prevent users from tripping up on that the compiler will return an error if it encounters type params until gopherjs#1013 is resolved.
- Loading branch information
1 parent
2db03cc
commit aa2dc78
Showing
4 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
//go:build js | ||
|
||
package doc | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
) | ||
|
||
func compareSlices(t *testing.T, name string, got, want interface{}, compareElem interface{}) { | ||
// TODO(nevkontakte): Remove this override after generics are supported. | ||
// https://github.com/gopherjs/gopherjs/issues/1013. | ||
switch got.(type) { | ||
case []*Func: | ||
got := got.([]*Func) | ||
want := want.([]*Func) | ||
compareElem := compareElem.(func(t *testing.T, msg string, got, want *Func)) | ||
if len(got) != len(want) { | ||
t.Errorf("%s: got %d, want %d", name, len(got), len(want)) | ||
} | ||
for i := 0; i < len(got) && i < len(want); i++ { | ||
compareElem(t, fmt.Sprintf("%s[%d]", name, i), got[i], want[i]) | ||
} | ||
case []*Type: | ||
got := got.([]*Type) | ||
want := want.([]*Type) | ||
compareElem := compareElem.(func(t *testing.T, msg string, got, want *Type)) | ||
if len(got) != len(want) { | ||
t.Errorf("%s: got %d, want %d", name, len(got), len(want)) | ||
} | ||
for i := 0; i < len(got) && i < len(want); i++ { | ||
compareElem(t, fmt.Sprintf("%s[%d]", name, i), got[i], want[i]) | ||
} | ||
default: | ||
t.Errorf("unexpected argument type %T", got) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters