Skip to content

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

@mdempsky

Description

@mdempsky

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions