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

cmd/compile: -W output shows "bool" instead of "untyped bool" #23833

Closed
mdempsky opened this issue Feb 14, 2018 · 1 comment
Closed

cmd/compile: -W output shows "bool" instead of "untyped bool" #23833

mdempsky opened this issue Feb 14, 2018 · 1 comment

Comments

@mdempsky
Copy link
Member

I was debugging #23414 by compiling

package p

type t struct {
    a, b struct{}
    _     int
}

with -W. In the output, there's

before type..eq."".t
.   RETURN l(1) tc(1)
.   RETURN-list
.   .   ANDAND l(1) tc(1) bool
.   .   .   EQ l(1) tc(1) bool
.   .   .   .   DOTPTR l(1) x(8) tc(1) p.a STRUCT-struct {}
.   .   .   .   .   NAME-p.p a(true) g(2) l(1) x(0) class(PPARAM) f(1) tc(1) used PTR64-*t
.   .   .   .   DOTPTR l(1) x(8) tc(1) p.a STRUCT-struct {}
.   .   .   .   .   NAME-p.q a(true) g(3) l(1) x(8) class(PPARAM) f(1) tc(1) used PTR64-*t
.   .   .   EQ l(1) tc(1) bool
.   .   .   .   DOTPTR l(1) x(8) tc(1) p.b STRUCT-struct {}
.   .   .   .   .   NAME-p.p a(true) g(2) l(1) x(0) class(PPARAM) f(1) tc(1) used PTR64-*t
.   .   .   .   DOTPTR l(1) x(8) tc(1) p.b STRUCT-struct {}
.   .   .   .   .   NAME-p.q a(true) g(3) l(1) x(8) class(PPARAM) f(1) tc(1) used PTR64-*t

This is misleading though: the OEQ nodes actually have type "untyped bool", not "bool".

This appears to be because of this code in typefmt:

           prefix := ""
           if mode == FErr && (t == types.Idealbool || t == types.Idealstring) {
               prefix = "untyped "
           }

I suspect we should also add the "untyped" prefix at least for FDbg mode (used by -W). We can maybe even just do it unconditionally, since I don't think we should ever be generating type IDs for untyped bools/strings. (And if we are, it's probably wrong to use the typed versions.)

/cc @griesemer

@gopherbot
Copy link

Change https://golang.org/cl/94021 mentions this issue: cmd/compile: fix printing of untyped types in -W output

@golang golang locked and limited conversation to collaborators Feb 14, 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

2 participants