Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/measure-size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-go@v2
with:
go-version: '~1.18.1'
go-version: '~1.18.4'
- uses: gopherjs/output-size-action/measure@main
with:
name: jQuery TodoMVC
Expand Down
2 changes: 2 additions & 0 deletions build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ func parseAndAugment(xctx XContext, pkg *PackageData, isTest bool, fileSet *toke
s := spec.(*ast.TypeSpec)
if replacedDeclNames[s.Name.Name] {
s.Name = ast.NewIdent("_")
s.Type = &ast.StructType{Struct: s.Pos(), Fields: &ast.FieldList{}}
s.TypeParams = nil
}
}
case token.VAR, token.CONST:
Expand Down
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ workflows:
parameters:
go_version:
type: string
default: "1.18.1"
default: "1.18.4"
nvm_version:
type: string
default: "0.38.0"
Expand Down
62 changes: 46 additions & 16 deletions compiler/natives/fs_vfsdata.go

Large diffs are not rendered by default.

37 changes: 37 additions & 0 deletions compiler/natives/src/go/doc/doc_test.go
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)
}
}
11 changes: 11 additions & 0 deletions compiler/natives/src/go/parser/parser_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//go:build js

package parser

import (
"testing"
)

func TestParseDepthLimit(t *testing.T) {
t.Skip("causes call stack exhaustion on js/ecmascript")
}
22 changes: 0 additions & 22 deletions compiler/natives/src/reflect/reflect.go
Original file line number Diff line number Diff line change
Expand Up @@ -1295,28 +1295,6 @@ func getJsTag(tag string) string {
return ""
}

// CanConvert reports whether the value v can be converted to type t. If
// v.CanConvert(t) returns true then v.Convert(t) will not panic.
//
// TODO(nevkontakte): this overlay can be removed after
// https://github.com/golang/go/pull/48346 is in the lastest stable Go release.
func (v Value) CanConvert(t Type) bool {
vt := v.Type()
if !vt.ConvertibleTo(t) {
return false
}
// Currently the only conversion that is OK in terms of type
// but that can panic depending on the value is converting
// from slice to pointer-to-array.
if vt.Kind() == Slice && t.Kind() == Ptr && t.Elem().Kind() == Array {
n := t.Elem().Len()
if n > v.Len() { // Avoiding use of unsafeheader.Slice here.
return false
}
}
return true
}

func (v Value) Index(i int) Value {
switch k := v.kind(); k {
case Array:
Expand Down
3 changes: 3 additions & 0 deletions compiler/natives/src/reflect/reflect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,9 @@ func TestMethodCallValueCodePtr(t *testing.T) {
t.Skip("methodValueCallCodePtr() is not applicable in GopherJS")
}

type B struct{}

//gopherjs:prune-original
func TestIssue50208(t *testing.T) {
t.Skip("This test required generics, which are not yet supported: https://github.com/gopherjs/gopherjs/issues/1013")
}
6 changes: 0 additions & 6 deletions compiler/natives/src/syscall/js/js.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@ func init() {

func ValueOf(x interface{}) Value {
switch x := x.(type) {
case Wrapper:
return x.JSValue()
case Value:
return x
case Func:
Expand Down Expand Up @@ -361,10 +359,6 @@ func (e *ValueError) Error() string {
return "syscall/js: call of " + e.Method + " on " + e.Type.String()
}

type Wrapper interface {
JSValue() Value
}

// CopyBytesToGo copies bytes from the Uint8Array src to dst.
// It returns the number of bytes copied, which will be the minimum of the lengths of src and dst.
// CopyBytesToGo panics if src is not an Uint8Array.
Expand Down
16 changes: 16 additions & 0 deletions compiler/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"go/ast"
"go/constant"
"go/scanner"
"go/token"
"go/types"
"sort"
Expand Down Expand Up @@ -398,6 +399,13 @@ func Compile(importPath string, files []*ast.File, fileSet *token.FileSet, impor
var mainFunc *types.Func
for _, fun := range functions {
o := funcCtx.pkgCtx.Defs[fun.Name].(*types.Func)

if fun.Type.TypeParams.NumFields() > 0 {
return nil, scanner.Error{
Pos: fileSet.Position(fun.Type.TypeParams.Pos()),
Msg: fmt.Sprintf("function %s: type parameters are not supported by GopherJS: https://github.com/gopherjs/gopherjs/issues/1013", o.Name()),
}
}
funcInfo := funcCtx.pkgCtx.FuncDeclInfos[o]
d := Decl{
FullName: o.FullName(),
Expand Down Expand Up @@ -480,6 +488,14 @@ func Compile(importPath string, files []*ast.File, fileSet *token.FileSet, impor
continue
}
typeName := funcCtx.objectName(o)

if named, ok := o.Type().(*types.Named); ok && named.TypeParams().Len() > 0 {
return nil, scanner.Error{
Pos: fileSet.Position(o.Pos()),
Msg: fmt.Sprintf("type %s: type parameters are not supported by GopherJS: https://github.com/gopherjs/gopherjs/issues/1013", o.Name()),
}
}

d := Decl{
Vars: []string{typeName},
DceObjectFilter: o.Name(),
Expand Down
2 changes: 1 addition & 1 deletion compiler/version_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

// Version is the GopherJS compiler version string.
const Version = "1.18.0+go1.18.1"
const Version = "1.18.0+go1.18.4"

// GoVersion is the current Go 1.x version that GopherJS is compatible with.
const GoVersion = 18
Expand Down
1 change: 1 addition & 0 deletions tests/gorepo/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ var knownFails = map[string]failReason{
"fixedbugs/issue49665.go": {category: other, desc: "attempts to pass -gcflags=-G=3 to enable generics, GopherJS doesn't expect the flag; re-enable in Go 1.19 where the flag is removed"},
"fixedbugs/issue48898.go": {category: other, desc: "https://github.com/gopherjs/gopherjs/issues/1128"},
"fixedbugs/issue48536.go": {category: usesUnsupportedPackage, desc: "https://github.com/gopherjs/gopherjs/issues/1130"},
"fixedbugs/issue53600.go": {category: lowLevelRuntimeDifference, desc: "GopherJS println format is different from Go's"},
}

type failCategory uint8
Expand Down