Skip to content

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

Closed

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

Activity

  1. gopherbot commented on Feb 14, 2018

    @gopherbot
    Contributor

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

  2. locked and limited conversation to collaborators on Feb 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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