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

go/types: type errors for untyped constants in shift operations #4901

Closed
kisielk opened this issue Feb 25, 2013 · 4 comments
Closed

go/types: type errors for untyped constants in shift operations #4901

kisielk opened this issue Feb 25, 2013 · 4 comments
Milestone

Comments

@kisielk
Copy link
Contributor

kisielk commented Feb 25, 2013

With revision 33d3e7bbd3ef, on Linux 64-bit compile the program from
http://play.golang.org/p/vcOARDUEC3 as "typecheck"

Then run:

$ go list std | grep -v cmd | xargs -n 1 ./typecheck 

The output is:

failed type check: /home/kamil/go/src/pkg/compress/lzw/reader.go:90:17: invalid
operation: mismatched types uint32 and int
failed type check: /home/kamil/go/src/pkg/debug/dwarf/buf.go:116:5: invalid operation:
mismatched types int64 and int
failed type check: /home/kamil/go/src/pkg/encoding/asn1/asn1.go:160:3: invalid
operation: mismatched types byte and int
failed type check: /home/kamil/go/src/pkg/exp/ssa/interp/interp.go:202:57: invalid
operation: instr (variable of type exp/ssa.Instruction) has no single field or method Pos
failed type check: /home/kamil/go/src/pkg/math/big/rat.go:140:15: invalid operation:
mismatched types uint64 and int
failed type check: /home/kamil/go/src/pkg/net/lookup_unix.go:56:20: undeclared name:
cgoLookupHost
failed type check: /home/kamil/go/src/pkg/os/types.go:64:6: invalid operation:
mismatched types FileMode and int
failed type check: /home/kamil/go/src/pkg/os/user/lookup.go:9:9: undeclared name: current
failed type check: /home/kamil/go/src/pkg/runtime/softfloat64.go:234:11: invalid
operation: mismatched types uint64 and int
failed type check: /home/kamil/go/src/pkg/strconv/atof.go:326:5: invalid operation:
cannot compare mant (variable of type uint64) == 2 << flt.mantbits (value of type
int)
failed type check: /home/kamil/go/src/pkg/text/scanner/scanner.go:540:6: invalid
operation: mismatched types uint64 and int

The errors regarding "mistmatched types T and int" refer to lines that look
like (example from the last line of output):

for s.Whitespace&(1<<uint(ch)) != 0 {

so it seems like the types package has trouble determining the correct type for the
shift expression.
@griesemer
Copy link
Contributor

Comment 2:

These are know bugs (see test cases in pkg/exp/gotype/gotype_test. Please do not file
more bugs against go/types. It is actively in the works.

Owner changed to @griesemer.

Status changed to Accepted.

@kisielk
Copy link
Contributor Author

kisielk commented Feb 25, 2013

Comment 3:

Sorry if you already knew about it, I couldn't find the issue that mentioned it (4538)
and I didn't realize there were also test cases in exp/gotype, I checked through the
ones in go/types.
I don't really understand the aversion against bugs being filed for this package. Since
it's pending inclusion in 1.1 isn't it better to track any issues that may come up,
despite it being in development?

@griesemer
Copy link
Contributor

Comment 4:

No worries. This particularly issue is just one that happens to be in the works right
now. Since there's still much in flux here, issues filed against it only cause more work
in this specific case. Note also that whether go/types stays in 1.1 is not yet decided -
there's an open issue) since putting it in 1.1 freezes the API and we may want to gain
more experience with it.

@griesemer
Copy link
Contributor

Comment 5:

This was fixed, likely by revision f10ff2e7c9bd (CL 7381052).
The suggested command above doesn't report any shift errors anymore, and after changing
the import in the "typecheck" command to:
    ctxt := build.Default
    ctxt.CgoEnabled = false
    pkg, err := ctxt.Import(pkgName, ".", 0)
it also doesn't report undeclared names.

Status changed to Fixed.

@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1maybe label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
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

4 participants