Skip to content

Go 1.11 support. #836

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dmitshur opened this issue Jun 26, 2018 · 8 comments
Closed

Go 1.11 support. #836

dmitshur opened this issue Jun 26, 2018 · 8 comments

Comments

@dmitshur
Copy link
Member

This is an issue to track work to support Go 1.11. go1.11beta1 has been released today.

@dmitshur
Copy link
Member Author

dmitshur commented Jun 29, 2018

I've started working on this on go1.11 branch. I've made good progress so far.

The current status is that most of the fundamental functionality is operational. Not all the tests are passing yet, but most are. The tests that are failing are mostly additions to Go 1.11 rather regressions in previous behavior. That includes new tests, and bug fixes/improvements applied during 1.11 cycle that will need to be adapted to GopherJS to get updated stricter tests to pass.

The current known failures on Linux (from CI) are:

  • crypto/des, TestEncryptTripleDES : Error: crypto/des: invalid buffer overlap
  • crypto/rc4, TestGolden : Error: crypto/rc4: invalid buffer overlap
  • go/doc, Test: difference in output, there are trailing " = " in consts that don't have explicit values (this failure looks fascinating, I'm very curious to find out what's causing it)
  • reflect, TestTypes: have struct { int32 int32; int64 int64 }, want struct { int32; int64 } (new testcase in Go 1.11, related to golang/go@9558ba2 and golang/gofrontend@023c3d4)
  • github.com/gopherjs/gopherjs/tests, TestGoRepositoryCompilerTests : 4 FAIL:
    • fixedbugs/issue21221.go: Error: fail
    • fixedbugs/issue22662.go: Error: got /tmp/issue22662.go.203426519:19015; want ??:1
    • fixedbugs/issue22662b.go: Error: runtime error: native function not implemented: syscall.runtime_BeforeFork (sounds like it'll need to be skipped due to use of unsupported os/exec)
    • fixedbugs/issue24547.go: Error: FAIL

That work is up next. However, the compiler seems to be largely functional already.

Edit: It's functional with go1.11beta1 but not yet go1.11beta2. See #845.

@paralin
Copy link
Contributor

paralin commented Aug 9, 2018

For go1.11beta3 I am currently getting the following error (using vgo):

..\..\..\..\..\..\..\..\Go\src\runtime\error.go:44:18: invalid operation: e.concrete (variable of type *_type) has no field or method pkgpath
..\..\..\..\..\..\..\..\Go\src\runtime\error.go:44:42: invalid operation: e.asserted (variable of type *_type) has no field or method pkgpath

Thanks for the hard work!

@dmitshur
Copy link
Member Author

dmitshur commented Aug 9, 2018

@paralin You’ll need the patch from PR #846 to fix that. I haven’t had a chance to merge it yet, but the change looks right from a quick look.

@dmitshur
Copy link
Member Author

I've fixed the crypto/des and crypto/rc4 test failures in 649d894. I'll copy the explanation from its commit message:

natives/crypto/internal/subtle: Implement for GopherJS.

Package crypto/internal/subtle is new to Go 1.11.
It's a copy of golang.org/x/crypto/internal/subtle,
added in golang/go@75d15a2.

There are two implementations: one uses unsafe, another uses reflect.
We can't use either because they both rely on pointer arithmetics,
which GopherJS doesn't support.

Create a custom impementation of AnyOverlap that makes use of
GopherJS slice internals.

Fixes crypto/des and crypto/rc4 tests.

@dmitshur
Copy link
Member Author

  • go/doc, Test: difference in output, there are trailing " = " in consts that don't have explicit values (this failure looks fascinating, I'm very curious to find out what's causing it)

Investigating this now. Confirmed it's a regression (in GopherJS 1.11 WIP). Made a smaller reproduce:

package main

import (
    "fmt"
    "go/ast"
    "go/doc"
    "go/parser"
    "go/printer"
    "go/token"
    "os"
)

func main() {
    fset := token.NewFileSet()
    f, err := parser.ParseFile(fset, "issue16153.go", src, 0)
    if err != nil {
        panic(err)
    }
    apkg := &ast.Package{
        Name: "issue16153",
        Files: map[string]*ast.File{
            "issue16153.go": f,
        },
    }
    doc := doc.New(apkg, "foo/bar/issue16153", 0)
    err = printer.Fprint(os.Stdout, fset, doc.Consts[0].Decl)
    if err != nil {
        panic(err)
    }
    fmt.Println()
}

const src = `package issue16153
const (
    x2 uint8 = 255
    Y2
)
`

After printing the AST, I can see the difference that's causing this:

image

Might be a reflect bug, so it's great this got caught.

@dmitshur
Copy link
Member Author

dmitshur commented Aug 19, 2018

Investigating it further, I learned that the issue was due to changes to go/doc between 1.10 and 1.11, and not in GopherJS 1.11 WIP itself. The first go/doc commit where the problem occurs was golang/go@c2366b2#diff-23c81667acc0871b0276b715d353197f.

It had this line, which was very suspect:

@@ -171,6 +199,7 @@ func (r *reader) filterSpec(spec ast.Spec) bool {
 		// always keep imports so we can collect them
 		return true
 	case *ast.ValueSpec:
+		s.Values = filterExprList(s.Values, ast.IsExported, true)
 		if len(s.Values) > 0 || s.Type == nil && len(s.Values) == 0 {
 			// If there are values declared on RHS, just replace the unexported
 			// identifiers on the LHS with underscore, so that it matches

After looking at the source of filterExprList, it was easy to guess that the GopherJS bug causing go/doc tests to fail in 1.11 was this subtle difference:

var s []int
s = s[0:0]
// s is []int(nil) in Go, but []int{} in GopherJS

Playground links confirming it:

The spec clearly defines this behavior:

If the sliced operand of a valid slice expression is a nil slice, the result is a nil slice.

(It's quite possible this is a reported issue in GopherJS, but hasn't been resolved yet.)

Edit: Reported as #851, and sent a fix in #852.

@dmitshur
Copy link
Member Author

dmitshur commented Aug 23, 2018

I've updated the go1.11 branch to Go 1.11 RC 2, and resolved the few remaining blocking issues. CI is now passing ✅ on that branch.

The go1.11 branch (PR #853) is now ready for review and testing. Please report any issues and opportunities to improve code. If there are no major issues discovered, the plan is to merge it when Go 1.11 is released.

dmitshur added a commit that referenced this issue Aug 25, 2018
@dmitshur
Copy link
Member Author

GopherJS 1.11-1 is now released and available on master branch.

Blog post: https://medium.com/gopherjs/gopherjs-1-11-1-is-released-7aad12f7e646.

Tweet: https://twitter.com/GopherJS/status/1033473977509982208.

GopherJS Playground has been updated: https://gopherjs.github.io/playground/#/1pp8a59LAX.

Thanks everyone! 🎉 🏄‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants