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

gollvm: invalid type conversion (type has no methods) #35739

Closed
heylinn opened this issue Nov 21, 2019 · 4 comments
Closed

gollvm: invalid type conversion (type has no methods) #35739

heylinn opened this issue Nov 21, 2019 · 4 comments
Assignees
Milestone

Comments

@heylinn
Copy link

@heylinn heylinn commented Nov 21, 2019

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

$ go version
go version go1.13 gollvm LLVM 10.0.0svn linux/amd64

Does this issue reproduce with the latest release?

Yes

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

$ uname -m -v

#1 SMP Debian 4.9.88-1+deb9u1 (2018-05-07) x86_64
$ cat /etc/debian_version 
9.4

What did you do?

$ git clone https://github.com/docker/docker-ce.git
$ cd docker-ce
$ git checkout v19.03.4
$ cd components
$ mkdir -p .gopath/src/github.com/docker
$ export GOPATH=`pwd`/.gopath:~/go
$ ln -sf `pwd`/engine .gopath/src/github.com/docker/docker
$ cd .gopath/src/github.com/docker/docker
$ go build -tags 'autogen netgo osusergo static_build' github.com/docker/docker/cmd/dockerd

What did you expect to see?

Clean compilation.

What did you see instead?

$ go build -tags 'autogen netgo osusergo static_build' github.com/docker/docker/cmd/dockerd
# github.com/docker/docker/daemon
.gopath/github.com/docker/docker/volume/service/errors.go:70:0: error: invalid type conversion (type has no methods)
@thanm
Copy link
Member

@thanm thanm commented Nov 21, 2019

I will take a look.

@thanm thanm self-assigned this Nov 21, 2019
@ianlancetaylor ianlancetaylor added this to the Gccgo milestone Nov 22, 2019
@Civil
Copy link

@Civil Civil commented Oct 10, 2020

There is a minimal test case (or mostly minimal) that I've managed to create:

test/main.go:

package main

import (
        "test/service"
)

func main() {
        _ = service.IsInUse(nil)
}

test/service/errors.go:

package service

const (
        errVolumeInUse conflictError = "volume is in use"
)

type conflictError string

func (e conflictError) Error() string {
        return string(e)
}

func IsInUse(err error) bool {
        return err == error(errVolumeInUse)
}

So far to workaround the issue it is enough to:

  1. Get rid of service package. If everything in main - it will compile.
  2. If I remove explicit type casting from IsInUse function.
  3. Snippet like that actually works fine:
func IsInUse(err error) bool {
        var e2 error
        e2 = errVolumeInUse
        _ = e2
        return e2 == err
}

but stops working if I remove _ = e2 line

EDIT: managed to simplify it a bit more.

@gopherbot
Copy link

@gopherbot gopherbot commented Oct 13, 2020

Change https://golang.org/cl/261662 mentions this issue: test: add test that fails with gofrontend

@thanm thanm assigned ianlancetaylor and unassigned thanm Oct 13, 2020
gopherbot pushed a commit that referenced this issue Oct 13, 2020
The gofrontend code doesn't correctly handle inlining a function that
refers to a constant with methods.

For #35739

Change-Id: I6bd0b5cd4272dbe9969634b4821e668acacfdcf9
Reviewed-on: https://go-review.googlesource.com/c/go/+/261662
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
@gopherbot
Copy link

@gopherbot gopherbot commented Oct 14, 2020

Change https://golang.org/cl/262437 mentions this issue: compiler: export type for string and bool constants

pull bot pushed a commit to Qwerty0x64/gcc that referenced this issue Oct 15, 2020
Also consolidate the identical code for constant type export into a
pair of static methods.

Fixes golang/go#35739

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/262437
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.