Skip to content
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

syscall/js: Compiler doesn't check implemented type #28913

Closed
sternix opened this issue Nov 21, 2018 · 2 comments
Closed

syscall/js: Compiler doesn't check implemented type #28913

sternix opened this issue Nov 21, 2018 · 2 comments

Comments

@sternix
Copy link

sternix commented Nov 21, 2018

What version of Go are you using (go version)?

$ go version devel +b44cd15464 Tue Nov 20 16:17:17 2018 +0000 freebsd/amd64

Does this issue reproduce with the latest release?

No only master

What operating system and processor architecture are you using (go env)?

go env Output
GOARCH="wasm"
GOBIN=""
GOCACHE="/home/sternix/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="freebsd"
GOOS="js"
GOPATH="/home/sternix/go"
GOPROXY=""
GORACE=""
GOROOT="/home/sternix/src/go"
GOTMPDIR=""
GOTOOLDIR="/home/sternix/src/go/pkg/tool/freebsd_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="0"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build888035731=/tmp/go-build -gno-record-gcc-switches"

What did you do?

write simple test program

package main

import "syscall/js"

type Wrapper interface {
        JSValue() js.Value
}

type x struct {
        js.Value
}

// first check
func newX() Wrapper {
        return &x {}
}

func main() {
        // second check
        var _ Wrapper = newX()
}

and compiled with

export GOARCH=wasm GOOS=js
go build -o abc.wasm abc.go

What did you expect to see?

with go 1.11.2 i have
./abc.go:13:9: cannot use x literal (type *x) as type Wrapper in return argument:
*x does not implement Wrapper (missing JSValue method)

What did you see instead?

go version devel +b44cd15464
i dont have any error
Compiled successfully

@cherrymui
Copy link
Member

*x does not implement Wrapper (missing JSValue method)

Why? Type x embeds js.Value, which does have JSValue method.

@sternix
Copy link
Author

sternix commented Nov 21, 2018

Thanks @cherrymui this is my fault i read 1.11.2 docs

https://golang.org/pkg/syscall/js/

which hasn't Value.JSValue

but tip has Value.JSValue

https://tip.golang.org/pkg/syscall/js/#Value.JSValue

Thanks for correction.

@sternix sternix closed this as completed Nov 21, 2018
@golang golang locked and limited conversation to collaborators Nov 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants