object88 / langd

A Language Server Protocol implementation in Go for Go
MIT License
7 stars 0 forks source link

Build issues #20

Closed object88 closed 6 years ago

object88 commented 6 years ago

Loading a large project (such as Hugo) with Go, Cgo, and Go Test (not External Go Test) files can cause issues with the type checker. The type checker will emit errors such as:

/usr/local/Cellar/go/1.9.2/libexec/src/net/lookup_test.go:73 cannot use t (variable of type */usr/local/Cellar/go/1.9.2/libexec/src/testing.T) as */usr/local/Cellar/go/1.9.2/libexec/src/testing.T value in argument to testenv.SkipFlakyNet

It appears that the type checker is getting confused about type comparisons. This only happens when including the Test pass; there are no errors otherwise.

Digging into a stack trace, it appears that the problem comes from a comparison of type instances. The error message makes it appear as though they are comparing apples to apples, however, they are actually different instances. When the code type checks on the second pass with Test included, the type package that the checker emits is replaced, and all the original instances are gone.

The solution to this problem is to only keep the first type package. This way, all the type instances are consistent.

This may cause issues later. A second solution may be to do the Go, Cgo, and Test all in one pass.