[go] go/types, types2: clean up Named assertions and establish RHS invariant

12 views
Skip to first unread message

Mark Freeman (Gerrit)

unread,
Aug 29, 2025, 3:49:01 PMAug 29
to goph...@pubsubhelper.golang.org, Go LUCI, Robert Findley, Robert Griesemer, golang-co...@googlegroups.com
Attention needed from Robert Findley

Mark Freeman voted and added 1 comment

Votes added by Mark Freeman

Commit-Queue+1

1 comment

Patchset-level comments
File-level comment, Patchset 22:
Robert Findley . resolved

Is this ready for review? Happy to review all or part of it--let me know what would be most helpful.

Mark Freeman

Pardon my delay — this is ready for review. Please note the breakage of x/tools is due to a compiler bug that an x/tools test relies on.

Open in Gerrit

Related details

Attention is currently required from:
  • Robert Findley
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I72644d7329c996eb1e67514063fe51c3ae06c38d
Gerrit-Change-Number: 695977
Gerrit-PatchSet: 26
Gerrit-Owner: Mark Freeman <markf...@google.com>
Gerrit-Reviewer: Mark Freeman <markf...@google.com>
Gerrit-Reviewer: Robert Findley <rfin...@google.com>
Gerrit-CC: Robert Griesemer <g...@google.com>
Gerrit-Attention: Robert Findley <rfin...@google.com>
Gerrit-Comment-Date: Fri, 29 Aug 2025 19:48:58 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Robert Findley <rfin...@google.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Mark Freeman (Gerrit)

unread,
Aug 29, 2025, 3:49:40 PMAug 29
to goph...@pubsubhelper.golang.org, Go LUCI, Robert Findley, Robert Griesemer, golang-co...@googlegroups.com
Attention needed from Robert Findley

Mark Freeman added 1 comment

Patchset-level comments
Robert Findley . resolved

Is this ready for review? Happy to review all or part of it--let me know what would be most helpful.

Mark Freeman

Pardon my delay — this is ready for review. Please note the breakage of x/tools is due to a compiler bug that an x/tools test relies on.

Mark Freeman

Review of the entire CL would be appreciated.

Open in Gerrit

Related details

Attention is currently required from:
  • Robert Findley
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I72644d7329c996eb1e67514063fe51c3ae06c38d
Gerrit-Change-Number: 695977
Gerrit-PatchSet: 26
Gerrit-Owner: Mark Freeman <markf...@google.com>
Gerrit-Reviewer: Mark Freeman <markf...@google.com>
Gerrit-Reviewer: Robert Findley <rfin...@google.com>
Gerrit-CC: Robert Griesemer <g...@google.com>
Gerrit-Attention: Robert Findley <rfin...@google.com>
Gerrit-Comment-Date: Fri, 29 Aug 2025 19:49:37 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Mark Freeman <markf...@google.com>
Comment-In-Reply-To: Robert Findley <rfin...@google.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Mark Freeman (Gerrit)

unread,
Sep 2, 2025, 5:32:25 PMSep 2
to goph...@pubsubhelper.golang.org, Go LUCI, Robert Findley, Robert Griesemer, golang-co...@googlegroups.com
Attention needed from Robert Findley

Mark Freeman voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Robert Findley
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I72644d7329c996eb1e67514063fe51c3ae06c38d
Gerrit-Change-Number: 695977
Gerrit-PatchSet: 28
Gerrit-Owner: Mark Freeman <markf...@google.com>
Gerrit-Reviewer: Mark Freeman <markf...@google.com>
Gerrit-Reviewer: Robert Findley <rfin...@google.com>
Gerrit-CC: Robert Griesemer <g...@google.com>
Gerrit-Attention: Robert Findley <rfin...@google.com>
Gerrit-Comment-Date: Tue, 02 Sep 2025 21:32:20 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
satisfied_requirement
open
diffy

Mark Freeman (Gerrit)

unread,
Sep 2, 2025, 5:34:53 PMSep 2
to goph...@pubsubhelper.golang.org, Go LUCI, Robert Findley, Robert Griesemer, golang-co...@googlegroups.com
Attention needed from Robert Findley

Mark Freeman voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Robert Findley
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I72644d7329c996eb1e67514063fe51c3ae06c38d
Gerrit-Change-Number: 695977
Gerrit-PatchSet: 29
Gerrit-Owner: Mark Freeman <markf...@google.com>
Gerrit-Reviewer: Mark Freeman <markf...@google.com>
Gerrit-Reviewer: Robert Findley <rfin...@google.com>
Gerrit-CC: Robert Griesemer <g...@google.com>
Gerrit-Attention: Robert Findley <rfin...@google.com>
Gerrit-Comment-Date: Tue, 02 Sep 2025 21:34:50 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
unsatisfied_requirement
satisfied_requirement
open
diffy

Robert Findley (Gerrit)

unread,
Sep 10, 2025, 12:57:09 PMSep 10
to Mark Freeman, goph...@pubsubhelper.golang.org, Go LUCI, Robert Griesemer, golang-co...@googlegroups.com
Attention needed from Mark Freeman

Robert Findley added 4 comments

Commit Message
Line 32, Patchset 30 (Latest): type has been deduced. One can check if the underlying is a
named type, but if the RHS was already a type literal, it's
still ambiguous.
Robert Findley . unresolved

Don't understand this. My mental model is that the underlying is either forwarded, or not. So if it's not Named, then we've already run the `under` algorithm. What am I missing?

File src/cmd/compile/internal/types2/named.go
Line 165, Patchset 30 (Latest): n.SetUnderlying(underlying)
Robert Findley . unresolved

This calls resolve(). I can't reason about the consequences of that... is this intentional? I always think of resolve() as something that happens lazily, and yet this is eager. Won't the underlying already have been set in newNamed?

At the very least, warrants a big comment explaining why we're setting the underlying twice.

Line 206, Patchset 30 (Latest): assert(n.loader == nil) // cannot import an instantiation
Robert Findley . unresolved

You certainly can import an instantiation, so this comment seems misleading.

Line 311, Patchset 30 (Latest): n.resolve().under()
Robert Findley . unresolved

This resolve is unnecessary. In general, we should only be calling resolve right before accessing the resolved information. In this case `Named.Underlying` calls resolve implicitly.

Open in Gerrit

Related details

Attention is currently required from:
  • Mark Freeman
Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I72644d7329c996eb1e67514063fe51c3ae06c38d
    Gerrit-Change-Number: 695977
    Gerrit-PatchSet: 30
    Gerrit-Owner: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Robert Findley <rfin...@google.com>
    Gerrit-CC: Robert Griesemer <g...@google.com>
    Gerrit-Attention: Mark Freeman <markf...@google.com>
    Gerrit-Comment-Date: Wed, 10 Sep 2025 16:57:05 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    Mark Freeman (Gerrit)

    unread,
    Sep 10, 2025, 3:26:51 PMSep 10
    to goph...@pubsubhelper.golang.org, Go LUCI, Robert Findley, Robert Griesemer, golang-co...@googlegroups.com
    Attention needed from Robert Findley

    Mark Freeman added 2 comments

    File src/cmd/compile/internal/types2/named.go
    Line 165, Patchset 30 (Latest): n.SetUnderlying(underlying)
    Robert Findley . unresolved

    This calls resolve(). I can't reason about the consequences of that... is this intentional? I always think of resolve() as something that happens lazily, and yet this is eager. Won't the underlying already have been set in newNamed?

    At the very least, warrants a big comment explaining why we're setting the underlying twice.

    Mark Freeman

    The `newNamed` never sets the underlying type. It only establishes the RHS, which we just set immediately to the underlying, as if it were declared in source.

    Calling `resolve()` is intentional — this CL enforces that only types which are resolved can have underlying types. It orders those operations.

    Robert Findley . unresolved

    This resolve is unnecessary. In general, we should only be calling resolve right before accessing the resolved information. In this case `Named.Underlying` calls resolve implicitly.

    Mark Freeman

    Calling `under` does not resolve the type for the caller. With this change, it asserts that the type has been resolved prior to being called.

    In this way, the expectations of `under` are explicit and surfaces an "out of phase" error.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Robert Findley
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I72644d7329c996eb1e67514063fe51c3ae06c38d
    Gerrit-Change-Number: 695977
    Gerrit-PatchSet: 30
    Gerrit-Owner: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Robert Findley <rfin...@google.com>
    Gerrit-CC: Robert Griesemer <g...@google.com>
    Gerrit-Attention: Robert Findley <rfin...@google.com>
    Gerrit-Comment-Date: Wed, 10 Sep 2025 19:26:46 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Robert Findley <rfin...@google.com>
    unsatisfied_requirement
    open
    diffy

    Robert Findley (Gerrit)

    unread,
    Sep 10, 2025, 3:29:43 PMSep 10
    to Mark Freeman, goph...@pubsubhelper.golang.org, Go LUCI, Robert Griesemer, golang-co...@googlegroups.com
    Attention needed from Mark Freeman

    Robert Findley added 1 comment

    Patchset-level comments
    File-level comment, Patchset 30 (Latest):
    Robert Findley . resolved

    Ack, clearly I missed the point in a superficial scan of this CL. It will take me several hours to review in earnest, which I likely won't have for some time; perhaps next week. Sorry.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Mark Freeman
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I72644d7329c996eb1e67514063fe51c3ae06c38d
    Gerrit-Change-Number: 695977
    Gerrit-PatchSet: 30
    Gerrit-Owner: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Robert Findley <rfin...@google.com>
    Gerrit-CC: Robert Griesemer <g...@google.com>
    Gerrit-Attention: Mark Freeman <markf...@google.com>
    Gerrit-Comment-Date: Wed, 10 Sep 2025 19:29:39 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    Mark Freeman (Gerrit)

    unread,
    Sep 10, 2025, 3:31:28 PMSep 10
    to goph...@pubsubhelper.golang.org, Go LUCI, Robert Findley, Robert Griesemer, golang-co...@googlegroups.com
    Attention needed from Robert Findley

    Mark Freeman added 2 comments

    Patchset-level comments
    Robert Findley . resolved

    Ack, clearly I missed the point in a superficial scan of this CL. It will take me several hours to review in earnest, which I likely won't have for some time; perhaps next week. Sorry.

    Mark Freeman

    No worries, thanks for taking a look.

    File src/cmd/compile/internal/types2/named.go
    Line 206, Patchset 30 (Latest): assert(n.loader == nil) // cannot import an instantiation
    Robert Findley . resolved

    You certainly can import an instantiation, so this comment seems misleading.

    Mark Freeman

    I assume this is resolved via discussion on go.dev/cl/697697.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Robert Findley
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I72644d7329c996eb1e67514063fe51c3ae06c38d
    Gerrit-Change-Number: 695977
    Gerrit-PatchSet: 30
    Gerrit-Owner: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Robert Findley <rfin...@google.com>
    Gerrit-CC: Robert Griesemer <g...@google.com>
    Gerrit-Attention: Robert Findley <rfin...@google.com>
    Gerrit-Comment-Date: Wed, 10 Sep 2025 19:31:23 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Robert Findley <rfin...@google.com>
    unsatisfied_requirement
    open
    diffy

    Robert Griesemer (Gerrit)

    unread,
    Oct 7, 2025, 1:39:22 PM (8 days ago) Oct 7
    to Mark Freeman, goph...@pubsubhelper.golang.org, Go LUCI, Robert Findley, golang-co...@googlegroups.com
    Attention needed from Mark Freeman

    Robert Griesemer added 6 comments

    Patchset-level comments
    Robert Griesemer . resolved

    Just some initial comments on the CL description.
    More to come.

    Commit Message
    Line 9, Patchset 30 (Latest):The RHS chain is a key feature for traversal of aliases; it refers to
    Robert Griesemer . unresolved

    Clearer:

    The RHS chain used by Named types is a key feature...

    Line 24, Patchset 30 (Latest):type of a. At some point during type checking, a walks the chain of
    Robert Griesemer . unresolved

    "a walks" is hard to read

    If you use capital letters for types, this becomes clearer.

    Line 29, Patchset 30 (Latest): 1. The underlying field may not refer to the underlying type,
    depending on when it is observed.
    Robert Griesemer . unresolved

    Whether the underlying field refers to the underlying type or not depends on when the field is accessed.

    Line 36, Patchset 30 (Latest):Operations derived from the underlying share similar caveats. For
    example, the expandUnderlying() method, which substitutes type
    arguments, returns an instantiated named type whose underlying
    also may or may not be its underlying type.
    Robert Griesemer . unresolved

    I think this could benefit from more precise prose. The problem is caused by the word "underlying" which is an adjective, a field name, and a specific type, depending on context. "underlying field" is slightly better, but also misleading for somebody not very familiar with the code. Since this is a longer exposition, it could make sense to introduce some terminology at the top for clarity. For instance, U-field for the field named underlying, U-type, for the underlying type, or something like this (better suggestions welcome).

    The basic idea (if I understand correctly) is to use the RHS field consistently by Named and Alias types, and the use the underlying and actual fields to represent the "resolved" state. I'd start with this at the top, rather than with the problem description.

    Line 42, Patchset 30 (Latest):same purpose as alias types. The underlying is not set until it
    Robert Griesemer . unresolved

    s/as/as for/ ?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Mark Freeman
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I72644d7329c996eb1e67514063fe51c3ae06c38d
    Gerrit-Change-Number: 695977
    Gerrit-PatchSet: 30
    Gerrit-Owner: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Robert Findley <rfin...@google.com>
    Gerrit-CC: Robert Griesemer <g...@google.com>
    Gerrit-Attention: Mark Freeman <markf...@google.com>
    Gerrit-Comment-Date: Tue, 07 Oct 2025 17:39:18 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    Mark Freeman (Gerrit)

    unread,
    Oct 7, 2025, 4:28:28 PM (8 days ago) Oct 7
    to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
    Attention needed from Mark Freeman

    Mark Freeman uploaded new patchset

    Mark Freeman uploaded patch set #32 to this change.
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Mark Freeman
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: newpatchset
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I72644d7329c996eb1e67514063fe51c3ae06c38d
    Gerrit-Change-Number: 695977
    Gerrit-PatchSet: 32
    unsatisfied_requirement
    open
    diffy

    Mark Freeman (Gerrit)

    unread,
    Oct 7, 2025, 4:29:30 PM (8 days ago) Oct 7
    to goph...@pubsubhelper.golang.org, Go LUCI, Robert Findley, Robert Griesemer, golang-co...@googlegroups.com
    Attention needed from Robert Findley and Robert Griesemer

    Mark Freeman added 6 comments

    Commit Message
    Line 9, Patchset 30:The RHS chain is a key feature for traversal of aliases; it refers to
    Robert Griesemer . unresolved

    Clearer:

    The RHS chain used by Named types is a key feature...

    Mark Freeman

    I began with Aliases to then relate it to the underlying field for Named, showing that these two concepts are similar in function.

    Do we want to jump straight to Named types at the start?

    Line 24, Patchset 30:type of a. At some point during type checking, a walks the chain of
    Robert Griesemer . resolved

    "a walks" is hard to read

    If you use capital letters for types, this becomes clearer.

    Mark Freeman

    Done

    Line 29, Patchset 30: 1. The underlying field may not refer to the underlying type,

    depending on when it is observed.
    Robert Griesemer . resolved

    Whether the underlying field refers to the underlying type or not depends on when the field is accessed.

    Mark Freeman

    Done

    Line 32, Patchset 30: type has been deduced. One can check if the underlying is a

    named type, but if the RHS was already a type literal, it's
    still ambiguous.
    Robert Findley . resolved

    Don't understand this. My mental model is that the underlying is either forwarded, or not. So if it's not Named, then we've already run the `under` algorithm. What am I missing?

    Mark Freeman

    Suppose `type t int`. Without running `under`, the `underlying` field of `t` points to `int`.

    So the type not being `Named` does not imply `under` was run.

    Line 36, Patchset 30:Operations derived from the underlying share similar caveats. For

    example, the expandUnderlying() method, which substitutes type
    arguments, returns an instantiated named type whose underlying
    also may or may not be its underlying type.
    Robert Griesemer . unresolved

    I think this could benefit from more precise prose. The problem is caused by the word "underlying" which is an adjective, a field name, and a specific type, depending on context. "underlying field" is slightly better, but also misleading for somebody not very familiar with the code. Since this is a longer exposition, it could make sense to introduce some terminology at the top for clarity. For instance, U-field for the field named underlying, U-type, for the underlying type, or something like this (better suggestions welcome).

    The basic idea (if I understand correctly) is to use the RHS field consistently by Named and Alias types, and the use the underlying and actual fields to represent the "resolved" state. I'd start with this at the top, rather than with the problem description.

    Mark Freeman

    That's the correct idea. Working on the prose now.

    Line 42, Patchset 30:same purpose as alias types. The underlying is not set until it
    Robert Griesemer . resolved

    s/as/as for/ ?

    Mark Freeman

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Robert Findley
    • Robert Griesemer
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I72644d7329c996eb1e67514063fe51c3ae06c38d
    Gerrit-Change-Number: 695977
    Gerrit-PatchSet: 32
    Gerrit-Owner: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Robert Findley <rfin...@google.com>
    Gerrit-CC: Robert Griesemer <g...@google.com>
    Gerrit-Attention: Robert Griesemer <g...@google.com>
    Gerrit-Attention: Robert Findley <rfin...@google.com>
    Gerrit-Comment-Date: Tue, 07 Oct 2025 20:29:25 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Robert Griesemer <g...@google.com>
    Comment-In-Reply-To: Robert Findley <rfin...@google.com>
    unsatisfied_requirement
    open
    diffy

    Robert Griesemer (Gerrit)

    unread,
    Oct 7, 2025, 9:52:01 PM (8 days ago) Oct 7
    to Mark Freeman, goph...@pubsubhelper.golang.org, Go LUCI, Robert Findley, golang-co...@googlegroups.com
    Attention needed from Mark Freeman and Robert Findley

    Robert Griesemer added 1 comment

    Commit Message
    Line 9, Patchset 30:The RHS chain is a key feature for traversal of aliases; it refers to
    Robert Griesemer . unresolved

    Clearer:

    The RHS chain used by Named types is a key feature...

    Mark Freeman

    I began with Aliases to then relate it to the underlying field for Named, showing that these two concepts are similar in function.

    Do we want to jump straight to Named types at the start?

    Robert Griesemer

    I think it may be better to explain the goal: use of fromRHS consistently to express the RHS as we encounter it in the syntax tree, and the use underlying/actual once we found those respective types.

    Maybe something like:

    A type definition or alias declaration consists of a type name (LHS) which is bound to a type expression (RHS) by the declaration.
    This CL consistently uses the fromRHS fields of Named and Alias types to represent that RHS type expression, and sets Named.underlying and Alias.actual only once those types have been computed.
    Currently, Named types used their underlying field for some of this functionality, which made it difficult to understand.

    Specifically, Named.underlying is not set until we have computed the underlying type; otherwise it is nil, providing a clear signal that we do not (yet) know that type.


    (As an aside, I never liked 'fromRHS', I wish we had a better name. But that's something we can easily change down the road.)

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Mark Freeman
    • Robert Findley
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I72644d7329c996eb1e67514063fe51c3ae06c38d
    Gerrit-Change-Number: 695977
    Gerrit-PatchSet: 32
    Gerrit-Owner: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Robert Findley <rfin...@google.com>
    Gerrit-CC: Robert Griesemer <g...@google.com>
    Gerrit-Attention: Mark Freeman <markf...@google.com>
    Gerrit-Attention: Robert Findley <rfin...@google.com>
    Gerrit-Comment-Date: Wed, 08 Oct 2025 01:51:56 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Robert Griesemer <g...@google.com>
    Comment-In-Reply-To: Mark Freeman <markf...@google.com>
    unsatisfied_requirement
    open
    diffy

    Robert Griesemer (Gerrit)

    unread,
    Oct 7, 2025, 10:07:36 PM (8 days ago) Oct 7
    to Mark Freeman, goph...@pubsubhelper.golang.org, Go LUCI, Robert Findley, golang-co...@googlegroups.com
    Attention needed from Mark Freeman and Robert Findley

    Robert Griesemer added 9 comments

    Patchset-level comments
    File-level comment, Patchset 32 (Latest):
    Robert Griesemer . resolved

    Some initial comment. Need to study named.go in more detail.

    File src/cmd/compile/internal/types2/named.go
    Line 110, Patchset 32 (Latest): // tags applied to named types in contexts where invariants can be applied only conditionally
    Robert Griesemer . unresolved

    These are not tags, they are (boolean) flags:

    // flags indicating temporary violations of the invariants for fromRHS and underlying

    Line 111, Patchset 32 (Latest): allowNilRHS bool
    Robert Griesemer . unresolved

    line comment explaining when this is possible?

    Line 112, Patchset 32 (Latest): allowNilUnderlying bool
    Robert Griesemer . unresolved

    ditto?

    Line 165, Patchset 32 (Latest): n.SetUnderlying(underlying)
    Robert Griesemer . unresolved

    should we assert here that underlying is not a Named type?

    Line 171, Patchset 32 (Latest):// resolve resolves the type parameters, methods, and RHS of n.
    Robert Griesemer . resolved

    Perhaps the right name for the field is _RHS (for another CL).

    Line 473, Patchset 32 (Latest): t.fromRHS = underlying
    Robert Griesemer . unresolved

    Is this necessary? What does it mean if underlying is not the real RHS?

    File src/cmd/compile/internal/types2/typexpr.go
    Line 420, Patchset 32 (Latest):func setDefType(def *TypeName, typ Type) {
    Robert Griesemer . resolved

    Maybe this should become setRHS? (Separate CL ok)

    File src/cmd/compile/internal/types2/unify.go
    Line 342, Patchset 32 (Latest): y = ny.resolve().under()
    Robert Griesemer . unresolved

    isn't under() calling resolve?

    (ditto elsewhere)

    Gerrit-Comment-Date: Wed, 08 Oct 2025 02:07:31 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    Mark Freeman (Gerrit)

    unread,
    Oct 8, 2025, 2:01:18 PM (7 days ago) Oct 8
    to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
    Attention needed from Mark Freeman and Robert Griesemer

    Mark Freeman uploaded new patchset

    Mark Freeman uploaded patch set #33 to this change.
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Mark Freeman
    • Robert Griesemer
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: newpatchset
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I72644d7329c996eb1e67514063fe51c3ae06c38d
    Gerrit-Change-Number: 695977
    Gerrit-PatchSet: 33
    Gerrit-Owner: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Robert Griesemer <g...@google.com>
    Gerrit-CC: Robert Findley <rfin...@google.com>
    Gerrit-Attention: Robert Griesemer <g...@google.com>
    Gerrit-Attention: Mark Freeman <markf...@google.com>
    unsatisfied_requirement
    open
    diffy

    Mark Freeman (Gerrit)

    unread,
    Oct 8, 2025, 2:07:19 PM (7 days ago) Oct 8
    to goph...@pubsubhelper.golang.org, Robert Findley, Robert Griesemer, Go LUCI, golang-co...@googlegroups.com
    Attention needed from Robert Findley and Robert Griesemer

    Mark Freeman added 10 comments

    Commit Message
    Line 9, Patchset 30:The RHS chain is a key feature for traversal of aliases; it refers to
    Robert Griesemer . resolved

    Clearer:

    The RHS chain used by Named types is a key feature...

    Mark Freeman

    I began with Aliases to then relate it to the underlying field for Named, showing that these two concepts are similar in function.

    Do we want to jump straight to Named types at the start?

    Robert Griesemer

    I think it may be better to explain the goal: use of fromRHS consistently to express the RHS as we encounter it in the syntax tree, and the use underlying/actual once we found those respective types.

    Maybe something like:

    A type definition or alias declaration consists of a type name (LHS) which is bound to a type expression (RHS) by the declaration.
    This CL consistently uses the fromRHS fields of Named and Alias types to represent that RHS type expression, and sets Named.underlying and Alias.actual only once those types have been computed.
    Currently, Named types used their underlying field for some of this functionality, which made it difficult to understand.

    Specifically, Named.underlying is not set until we have computed the underlying type; otherwise it is nil, providing a clear signal that we do not (yet) know that type.


    (As an aside, I never liked 'fromRHS', I wish we had a better name. But that's something we can easily change down the road.)

    Mark Freeman

    Incorporated much of the suggestions here

    Line 36, Patchset 30:Operations derived from the underlying share similar caveats. For
    example, the expandUnderlying() method, which substitutes type
    arguments, returns an instantiated named type whose underlying
    also may or may not be its underlying type.
    Robert Griesemer . resolved

    I think this could benefit from more precise prose. The problem is caused by the word "underlying" which is an adjective, a field name, and a specific type, depending on context. "underlying field" is slightly better, but also misleading for somebody not very familiar with the code. Since this is a longer exposition, it could make sense to introduce some terminology at the top for clarity. For instance, U-field for the field named underlying, U-type, for the underlying type, or something like this (better suggestions welcome).

    The basic idea (if I understand correctly) is to use the RHS field consistently by Named and Alias types, and the use the underlying and actual fields to represent the "resolved" state. I'd start with this at the top, rather than with the problem description.

    Mark Freeman

    That's the correct idea. Working on the prose now.

    Mark Freeman

    Used Named.underlying to make it a bit clearer when we are referring to the field and the term underlying type to make it clear when we are talking about the type.

    File src/cmd/compile/internal/types2/named.go
    Line 110, Patchset 32: // tags applied to named types in contexts where invariants can be applied only conditionally
    Robert Griesemer . resolved

    These are not tags, they are (boolean) flags:

    // flags indicating temporary violations of the invariants for fromRHS and underlying

    Mark Freeman

    Done

    Line 111, Patchset 32: allowNilRHS bool
    Robert Griesemer . resolved

    line comment explaining when this is possible?

    Mark Freeman

    Done

    Line 112, Patchset 32: allowNilUnderlying bool
    Robert Griesemer . resolved

    ditto?

    Mark Freeman

    Done

    Line 165, Patchset 30: n.SetUnderlying(underlying)
    Robert Findley . resolved

    This calls resolve(). I can't reason about the consequences of that... is this intentional? I always think of resolve() as something that happens lazily, and yet this is eager. Won't the underlying already have been set in newNamed?

    At the very least, warrants a big comment explaining why we're setting the underlying twice.

    Mark Freeman

    The `newNamed` never sets the underlying type. It only establishes the RHS, which we just set immediately to the underlying, as if it were declared in source.

    Calling `resolve()` is intentional — this CL enforces that only types which are resolved can have underlying types. It orders those operations.

    Mark Freeman

    Acknowledged

    Line 165, Patchset 32: n.SetUnderlying(underlying)
    Robert Griesemer . unresolved

    should we assert here that underlying is not a Named type?

    Mark Freeman

    FWIW, `SetUnderlying` already makes this assertion, unless you're suggesting to duplicate this assertion?

    Line 311, Patchset 30: n.resolve().under()
    Robert Findley . resolved

    This resolve is unnecessary. In general, we should only be calling resolve right before accessing the resolved information. In this case `Named.Underlying` calls resolve implicitly.

    Mark Freeman

    Calling `under` does not resolve the type for the caller. With this change, it asserts that the type has been resolved prior to being called.

    In this way, the expectations of `under` are explicit and surfaces an "out of phase" error.

    Mark Freeman

    Acknowledged

    Line 473, Patchset 32: t.fromRHS = underlying
    Robert Griesemer . unresolved

    Is this necessary? What does it mean if underlying is not the real RHS?

    Mark Freeman

    IIRC, this `SetUnderlying` should ideally only be called for cases where we know the underlying type already, such as for importers and things in the universe.

    In that case, this just makes it follow the same flow as type checking from source — make a trivial RHS, resolve it, and set the underlying.

    File src/cmd/compile/internal/types2/unify.go
    Line 342, Patchset 32: y = ny.resolve().under()
    Robert Griesemer . unresolved

    isn't under() calling resolve?

    (ditto elsewhere)

    Mark Freeman

    The function `under` indeed calls `resolve`. The method `Named.under` does not.

    This CL changed the implementation of the method — it begins by asserting that the input Named type has been resolved. The thought was to surface this ordering explicitly to the caller, rather than implicitly handling it in under.

    It's harder to do this for the function, since it's a) used in many more places and b) in contexts where we do not know if it's a named.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Robert Findley
    • Robert Griesemer
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I72644d7329c996eb1e67514063fe51c3ae06c38d
    Gerrit-Change-Number: 695977
    Gerrit-PatchSet: 33
    Gerrit-Owner: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Robert Griesemer <g...@google.com>
    Gerrit-CC: Robert Findley <rfin...@google.com>
    Gerrit-Attention: Robert Griesemer <g...@google.com>
    Gerrit-Attention: Robert Findley <rfin...@google.com>
    Gerrit-Comment-Date: Wed, 08 Oct 2025 18:07:14 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Robert Griesemer <g...@google.com>
    Comment-In-Reply-To: Mark Freeman <markf...@google.com>
    Comment-In-Reply-To: Robert Findley <rfin...@google.com>
    unsatisfied_requirement
    open
    diffy

    Robert Griesemer (Gerrit)

    unread,
    Oct 9, 2025, 7:08:39 PM (6 days ago) Oct 9
    to Mark Freeman, goph...@pubsubhelper.golang.org, Robert Findley, Go LUCI, golang-co...@googlegroups.com
    Attention needed from Mark Freeman

    Robert Griesemer added 34 comments

    Patchset-level comments
    File-level comment, Patchset 33 (Latest):
    Robert Griesemer . resolved

    Some more comments.
    Overall looks pretty reasonable, but I have added some questions.

    Commit Message
    Line 17, Patchset 33 (Latest):functionality, which made it difficult to understand. Operations which
    Robert Griesemer . unresolved

    s/made it/makes the code/

    Line 18, Patchset 33 (Latest):used Named.underlying for this functionality now use Named.fromRHS.
    Robert Griesemer . unresolved

    s/for this functionality//

    Line 44, Patchset 33 (Latest): type has been deduced. One can check if Named.underlying is

    a named type, but if the RHS was already a type literal, it's
    still ambiguous.
    Robert Griesemer . unresolved

    I don't understand this 2nd sentence here: if the RHS is a type literal, then underlying would be that type literal eventually. And it is nil before. At least for a type definition.

    Line 53, Patchset 33 (Latest):With this change, presence of Named.underlying becomes the canonical
    Robert Griesemer . unresolved

    Clearer (w/o resorting to under() which you haven't mentioned in this CL desc yet):

    With this change, Named.underlying is nil as long as it is unknown, and non-nil and not a named type once it is known.

    Line 57, Patchset 33 (Latest): 1. A named type cannot populate Named.underlying until it has been
    Robert Griesemer . unresolved

    1. Named.underlying is not set until Named has been resolved.

    Line 68, Patchset 33 (Latest):type to already be resolved. In that case, it's best to assert it.
    Robert Griesemer . unresolved

    s/In that case, it's best to assert it.//

    Line 73, Patchset 33 (Latest):is exploited by a test (issue61678.go) in x/tools.
    Robert Griesemer . unresolved

    So what is the action Here?

    File src/cmd/compile/internal/types2/decl.go
    Line 555, Patchset 33 (Latest): // The RHS of a named can be nil if there's a cycle of non-reified aliases. There is likely a
    Robert Griesemer . unresolved

    This is the first use of reify in this code base. It's not defined what it means. Also this comment applies to the next line.

    Can you add a simple example to clarify this?

    Line 558, Patchset 33 (Latest): named.allowNilRHS = true
    Robert Griesemer . unresolved

    use a defer here - this ensures correct behavior (invariants) in case one of the functions below panics (e.g. early exit after first error). It may not matter in this case but it's good code hygiene.

    named.allowNilRHS = true
    defer func() { named.allowNilRHS = false } ()

    Line 570, Patchset 33 (Latest): named.allowNilRHS = false
    Robert Griesemer . unresolved

    remove this in favor of defer above

    File src/cmd/compile/internal/types2/named.go
    Line 147, Patchset 33 (Latest): unresolved namedState = iota // type parameters, RHS, and methods might be unavailable
    Robert Griesemer . unresolved

    ... RHS, underlying, and methods ...

    (?) or, depending on my comment below (line 473), maybe just:

    ... underlying, and methods ...

    (?)

    Line 165, Patchset 32: n.SetUnderlying(underlying)
    Robert Griesemer . resolved

    should we assert here that underlying is not a Named type?

    Mark Freeman

    FWIW, `SetUnderlying` already makes this assertion, unless you're suggesting to duplicate this assertion?

    Robert Griesemer

    ACK. Marked as resolved.

    Line 191, Patchset 33 (Latest): if n.state() > unresolved { // avoid locking below
    Robert Griesemer . unresolved

    n.state() >= resolved

    makes it clearer that n is already resolved (as is, we need to check if the next state after unresolved is indeed resolve)

    This is also the code you use in line 556

    Line 200, Patchset 33 (Latest): if n.state() > unresolved {
    Robert Griesemer . unresolved

    ditto

    Line 249, Patchset 33 (Latest): assert(n.underlying == nil) // underlying comes after resolving
    Robert Griesemer . unresolved

    I don't understand this: aren't we past resolving (we set the state to complete in the next instruction)

    Line 473, Patchset 32: t.fromRHS = underlying
    Robert Griesemer . unresolved

    Is this necessary? What does it mean if underlying is not the real RHS?

    Mark Freeman

    IIRC, this `SetUnderlying` should ideally only be called for cases where we know the underlying type already, such as for importers and things in the universe.

    In that case, this just makes it follow the same flow as type checking from source — make a trivial RHS, resolve it, and set the underlying.

    Robert Griesemer

    ACK. Since we now have a clear separation between RHS and underlying, couldn't we keep RHS nil if it doesn't actually exist in the source? That is, for imported types and things in the universe?

    (I see that this would required changes to expndRHS below. Just trying to understand this code.)

    Line 546, Patchset 33 (Latest):// It does so by following type chains. If a type literal is found, each
    Robert Griesemer . unresolved

    ... by following RHS type chains. ...

    Line 548, Patchset 33 (Latest):// are skipped because their underlying type is not memoized.
    Robert Griesemer . unresolved

    I don't understand this last sentence. Alias types don't have an underlying field.

    Line 564, Patchset 33 (Latest): var path []Object
    Robert Griesemer . unresolved

    declare path after seen, as it is used after seen in typical use below

    Line 567, Patchset 33 (Latest): for {
    Robert Griesemer . unresolved
    var u Type
    for u != nil {
    ...

    and then you can remove some of the break's below and you don't need a loop label
    Line 568, Patchset 33 (Latest): switch curr := t.(type) {
    Robert Griesemer . unresolved

    s/t/rhs/ (plus appropriate decl above)
    s/curr/t/

    Line 571, Patchset 33 (Latest): break loop
    Robert Griesemer . unresolved

    don't need the break

    Line 578, Patchset 33 (Latest): break loop
    Robert Griesemer . unresolved

    just break (no need for loop)

    Line 589, Patchset 33 (Latest): break loop // any type literal works
    Robert Griesemer . unresolved

    no need for break

    Line 591, Patchset 33 (Latest): }
    Robert Griesemer . unresolved

    Immediately after the loop, as a reminder you could add:

    // u != nil

    Line 598, Patchset 33 (Latest): assert(u != nil)
    Robert Griesemer . unresolved

    no need for this assertion, it's guaranteed by the loop termination condition

    Line 600, Patchset 33 (Parent): u = n.Underlying()
    Robert Griesemer . resolved

    nice to get the call to Underlying out of this loop!

    Line 625, Patchset 33 (Latest):// its origin type (which is a generic type).
    Robert Griesemer . unresolved

    s/is/must be/ (?)

    Line 629, Patchset 33 (Latest):// type t[p any] struct {
    Robert Griesemer . unresolved

    please use capital letters for type names and type parameters

    Line 675, Patchset 33 (Latest): assert(orig.state() > unresolved)
    Robert Griesemer . unresolved

    `>= resolved`

    Line 721, Patchset 33 (Latest): return iface
    Robert Griesemer . unresolved

    we can fall through here, can't we?

    File src/cmd/compile/internal/types2/unify.go
    Line 342, Patchset 32: y = ny.resolve().under()
    Robert Griesemer . resolved

    isn't under() calling resolve?

    (ditto elsewhere)

    Mark Freeman

    The function `under` indeed calls `resolve`. The method `Named.under` does not.

    This CL changed the implementation of the method — it begins by asserting that the input Named type has been resolved. The thought was to surface this ordering explicitly to the caller, rather than implicitly handling it in under.

    It's harder to do this for the function, since it's a) used in many more places and b) in contexts where we do not know if it's a named.

    Robert Griesemer

    Acknowledged

    File src/cmd/compile/internal/types2/universe.go
    Line 131, Patchset 33 (Latest): typ.fromRHS = ityp
    Robert Griesemer . unresolved

    Again, I wonder if we can avoid this since there's no real RHS

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Mark Freeman
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I72644d7329c996eb1e67514063fe51c3ae06c38d
    Gerrit-Change-Number: 695977
    Gerrit-PatchSet: 33
    Gerrit-Owner: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Robert Griesemer <g...@google.com>
    Gerrit-CC: Robert Findley <rfin...@google.com>
    Gerrit-Attention: Mark Freeman <markf...@google.com>
    Gerrit-Comment-Date: Thu, 09 Oct 2025 23:08:35 +0000
    unsatisfied_requirement
    open
    diffy

    Mark Freeman (Gerrit)

    unread,
    Oct 14, 2025, 2:25:11 PM (yesterday) Oct 14
    to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
    Attention needed from Mark Freeman

    Mark Freeman uploaded new patchset

    Mark Freeman uploaded patch set #34 to this change.
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Mark Freeman
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: newpatchset
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I72644d7329c996eb1e67514063fe51c3ae06c38d
    Gerrit-Change-Number: 695977
    Gerrit-PatchSet: 34
    unsatisfied_requirement
    open
    diffy

    Mark Freeman (Gerrit)

    unread,
    Oct 14, 2025, 2:30:12 PM (yesterday) Oct 14
    to goph...@pubsubhelper.golang.org, Robert Findley, Robert Griesemer, Go LUCI, golang-co...@googlegroups.com
    Attention needed from Robert Griesemer

    Mark Freeman added 10 comments

    Commit Message
    Line 44, Patchset 33: type has been deduced. One can check if Named.underlying is

    a named type, but if the RHS was already a type literal, it's
    still ambiguous.
    Robert Griesemer . unresolved

    I don't understand this 2nd sentence here: if the RHS is a type literal, then underlying would be that type literal eventually. And it is nil before. At least for a type definition.

    Mark Freeman

    This refers to Named.underlying as it was previously used — not with this change. As in, suppose `type B int`, even without calling `under`, `Named.underlying` would already be `int`.

    Line 73, Patchset 33:is exploited by a test (issue61678.go) in x/tools.
    Robert Griesemer . unresolved

    So what is the action Here?

    Mark Freeman

    No action, we dropped the test for 1.26 via go.dev/cl/700395.

    File src/cmd/compile/internal/types2/named.go
    Line 191, Patchset 33: if n.state() > unresolved { // avoid locking below
    Robert Griesemer . resolved

    n.state() >= resolved

    makes it clearer that n is already resolved (as is, we need to check if the next state after unresolved is indeed resolve)

    This is also the code you use in line 556

    Mark Freeman

    Done

    Line 200, Patchset 33: if n.state() > unresolved {
    Robert Griesemer . resolved

    ditto

    Mark Freeman

    Done

    Line 249, Patchset 33: assert(n.underlying == nil) // underlying comes after resolving
    Robert Griesemer . unresolved

    I don't understand this: aren't we past resolving (we set the state to complete in the next instruction)

    Mark Freeman

    I think complete is mostly orthogonal to N.underlying. We are still in N.resolve and so we cannot have called N.under.

    Line 473, Patchset 32: t.fromRHS = underlying
    Robert Griesemer . unresolved

    Is this necessary? What does it mean if underlying is not the real RHS?

    Mark Freeman

    IIRC, this `SetUnderlying` should ideally only be called for cases where we know the underlying type already, such as for importers and things in the universe.

    In that case, this just makes it follow the same flow as type checking from source — make a trivial RHS, resolve it, and set the underlying.

    Robert Griesemer

    ACK. Since we now have a clear separation between RHS and underlying, couldn't we keep RHS nil if it doesn't actually exist in the source? That is, for imported types and things in the universe?

    (I see that this would required changes to expndRHS below. Just trying to understand this code.)

    Mark Freeman

    We likely could for the cases you mentioned.

    It just seemed simpler to me to fold one case into the other to reduce the cases that the rest of the code must consider. For example, for imported types, it seemed natural to consider the underlying type from export data as the RHS and thus get the invariant that RHS cannot be nil (outside the cases where we allow it).

    Line 546, Patchset 33:// It does so by following type chains. If a type literal is found, each
    Robert Griesemer . resolved

    ... by following RHS type chains. ...

    Mark Freeman

    Done

    Line 548, Patchset 33:// are skipped because their underlying type is not memoized.
    Robert Griesemer . unresolved

    I don't understand this last sentence. Alias types don't have an underlying field.

    Mark Freeman

    Correct, though they still need to be traversed and they are not set when we find our first type literal. We can only do that because they walk to the nearest `Named` type when their `Underlying` is called.

    Robert Griesemer . unresolved
    var u Type
    for u != nil {
    ...

    and then you can remove some of the break's below and you don't need a loop label
    Mark Freeman

    If `var u Type`, how do we enter the loop?

    Robert Griesemer . resolved

    nice to get the call to Underlying out of this loop!

    Mark Freeman

    Thanks!

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Robert Griesemer
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I72644d7329c996eb1e67514063fe51c3ae06c38d
    Gerrit-Change-Number: 695977
    Gerrit-PatchSet: 34
    Gerrit-Owner: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Robert Griesemer <g...@google.com>
    Gerrit-CC: Robert Findley <rfin...@google.com>
    Gerrit-Attention: Robert Griesemer <g...@google.com>
    Gerrit-Comment-Date: Tue, 14 Oct 2025 18:30:08 +0000
    unsatisfied_requirement
    open
    diffy

    Mark Freeman (Gerrit)

    unread,
    Oct 14, 2025, 3:09:08 PM (yesterday) Oct 14
    to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
    Attention needed from Robert Griesemer

    Mark Freeman uploaded new patchset

    Mark Freeman uploaded patch set #35 to this change.
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Robert Griesemer
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: newpatchset
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I72644d7329c996eb1e67514063fe51c3ae06c38d
    Gerrit-Change-Number: 695977
    Gerrit-PatchSet: 35
    unsatisfied_requirement
    open
    diffy

    Mark Freeman (Gerrit)

    unread,
    Oct 14, 2025, 3:12:31 PM (yesterday) Oct 14
    to goph...@pubsubhelper.golang.org, Robert Findley, Robert Griesemer, Go LUCI, golang-co...@googlegroups.com
    Attention needed from Robert Griesemer

    Mark Freeman added 6 comments

    Commit Message
    Line 17, Patchset 33:functionality, which made it difficult to understand. Operations which
    Robert Griesemer . resolved

    s/made it/makes the code/

    Mark Freeman

    Done

    Line 18, Patchset 33:used Named.underlying for this functionality now use Named.fromRHS.
    Robert Griesemer . resolved

    s/for this functionality//

    Mark Freeman

    Done

    Line 53, Patchset 33:With this change, presence of Named.underlying becomes the canonical
    Robert Griesemer . resolved

    Clearer (w/o resorting to under() which you haven't mentioned in this CL desc yet):

    With this change, Named.underlying is nil as long as it is unknown, and non-nil and not a named type once it is known.

    Mark Freeman

    Done

    Line 57, Patchset 33: 1. A named type cannot populate Named.underlying until it has been
    Robert Griesemer . resolved

    1. Named.underlying is not set until Named has been resolved.

    Mark Freeman

    Done

    Line 68, Patchset 33:type to already be resolved. In that case, it's best to assert it.
    Robert Griesemer . resolved

    s/In that case, it's best to assert it.//

    Mark Freeman

    Done

    File src/cmd/compile/internal/types2/named.go
    Line 675, Patchset 33: assert(orig.state() > unresolved)
    Robert Griesemer . resolved

    `>= resolved`

    Mark Freeman

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Robert Griesemer
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I72644d7329c996eb1e67514063fe51c3ae06c38d
    Gerrit-Change-Number: 695977
    Gerrit-PatchSet: 35
    Gerrit-Owner: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Robert Griesemer <g...@google.com>
    Gerrit-CC: Robert Findley <rfin...@google.com>
    Gerrit-Attention: Robert Griesemer <g...@google.com>
    Gerrit-Comment-Date: Tue, 14 Oct 2025 19:12:27 +0000
    unsatisfied_requirement
    open
    diffy

    Robert Griesemer (Gerrit)

    unread,
    Oct 14, 2025, 4:31:31 PM (yesterday) Oct 14
    to Mark Freeman, goph...@pubsubhelper.golang.org, Robert Findley, Go LUCI, golang-co...@googlegroups.com
    Attention needed from Mark Freeman

    Robert Griesemer added 1 comment

    Commit Message
    Line 44, Patchset 33: type has been deduced. One can check if Named.underlying is
    a named type, but if the RHS was already a type literal, it's
    still ambiguous.
    Robert Griesemer . unresolved

    I don't understand this 2nd sentence here: if the RHS is a type literal, then underlying would be that type literal eventually. And it is nil before. At least for a type definition.

    Mark Freeman

    This refers to Named.underlying as it was previously used — not with this change. As in, suppose `type B int`, even without calling `under`, `Named.underlying` would already be `int`.

    Robert Griesemer

    I see. I was confused because `int` in this case is not a type literal. It is a named, albeit predeclared, type.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Mark Freeman
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I72644d7329c996eb1e67514063fe51c3ae06c38d
    Gerrit-Change-Number: 695977
    Gerrit-PatchSet: 35
    Gerrit-Owner: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Robert Griesemer <g...@google.com>
    Gerrit-CC: Robert Findley <rfin...@google.com>
    Gerrit-Attention: Mark Freeman <markf...@google.com>
    Gerrit-Comment-Date: Tue, 14 Oct 2025 20:31:26 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Robert Griesemer <g...@google.com>
    Comment-In-Reply-To: Mark Freeman <markf...@google.com>
    unsatisfied_requirement
    open
    diffy

    Robert Griesemer (Gerrit)

    unread,
    Oct 14, 2025, 4:48:19 PM (yesterday) Oct 14
    to Mark Freeman, goph...@pubsubhelper.golang.org, Robert Findley, Go LUCI, golang-co...@googlegroups.com
    Attention needed from Mark Freeman

    Robert Griesemer added 1 comment

    File src/cmd/compile/internal/types2/named.go
    Robert Griesemer . unresolved
    var u Type
    for u != nil {
    ...

    and then you can remove some of the break's below and you don't need a loop label
    Mark Freeman

    If `var u Type`, how do we enter the loop?

    Robert Griesemer

    I meant
    `for u == nil ...`
    of course. Sorry.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Mark Freeman
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I72644d7329c996eb1e67514063fe51c3ae06c38d
    Gerrit-Change-Number: 695977
    Gerrit-PatchSet: 35
    Gerrit-Owner: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Robert Griesemer <g...@google.com>
    Gerrit-CC: Robert Findley <rfin...@google.com>
    Gerrit-Attention: Mark Freeman <markf...@google.com>
    Gerrit-Comment-Date: Tue, 14 Oct 2025 20:48:15 +0000
    unsatisfied_requirement
    open
    diffy

    Mark Freeman (Gerrit)

    unread,
    Oct 14, 2025, 6:32:30 PM (yesterday) Oct 14
    to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
    Attention needed from Mark Freeman

    Mark Freeman uploaded new patchset

    Mark Freeman uploaded patch set #36 to this change.
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Mark Freeman
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: newpatchset
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I72644d7329c996eb1e67514063fe51c3ae06c38d
    Gerrit-Change-Number: 695977
    Gerrit-PatchSet: 36
    unsatisfied_requirement
    open
    diffy

    Mark Freeman (Gerrit)

    unread,
    Oct 14, 2025, 6:34:11 PM (yesterday) Oct 14
    to goph...@pubsubhelper.golang.org, Robert Findley, Robert Griesemer, Go LUCI, golang-co...@googlegroups.com
    Attention needed from Robert Griesemer

    Mark Freeman added 13 comments

    Patchset-level comments
    File-level comment, Patchset 36 (Latest):
    Mark Freeman . resolved

    Another batch of responses, just working on the remaining comments.

    File src/cmd/compile/internal/types2/decl.go
    Line 558, Patchset 33: named.allowNilRHS = true
    Robert Griesemer . resolved

    use a defer here - this ensures correct behavior (invariants) in case one of the functions below panics (e.g. early exit after first error). It may not matter in this case but it's good code hygiene.

    named.allowNilRHS = true
    defer func() { named.allowNilRHS = false } ()

    Mark Freeman

    Done

    Line 570, Patchset 33: named.allowNilRHS = false
    Robert Griesemer . resolved

    remove this in favor of defer above

    Mark Freeman

    Done

    File src/cmd/compile/internal/types2/named.go
    Line 564, Patchset 33: var path []Object
    Robert Griesemer . resolved

    declare path after seen, as it is used after seen in typical use below

    Mark Freeman

    Done

    Robert Griesemer . resolved
    var u Type
    for u != nil {
    ...

    and then you can remove some of the break's below and you don't need a loop label
    Mark Freeman

    If `var u Type`, how do we enter the loop?

    Robert Griesemer

    I meant
    `for u == nil ...`
    of course. Sorry.

    Mark Freeman

    Done

    Line 568, Patchset 33: switch curr := t.(type) {
    Robert Griesemer . resolved

    s/t/rhs/ (plus appropriate decl above)
    s/curr/t/

    Mark Freeman

    Done

    Line 571, Patchset 33: break loop
    Robert Griesemer . resolved

    don't need the break

    Mark Freeman

    Done

    Line 578, Patchset 33: break loop
    Robert Griesemer . resolved

    just break (no need for loop)

    Mark Freeman

    Done

    Line 589, Patchset 33: break loop // any type literal works
    Robert Griesemer . resolved

    no need for break

    Mark Freeman

    Done

    Line 591, Patchset 33: }
    Robert Griesemer . resolved

    Immediately after the loop, as a reminder you could add:

    // u != nil

    Mark Freeman

    Acknowledged, feel the loop condition is obvious enough

    Line 598, Patchset 33: assert(u != nil)
    Robert Griesemer . resolved

    no need for this assertion, it's guaranteed by the loop termination condition

    Mark Freeman

    Done

    Line 625, Patchset 33:// its origin type (which is a generic type).
    Robert Griesemer . resolved

    s/is/must be/ (?)

    Mark Freeman

    Done

    Line 629, Patchset 33:// type t[p any] struct {
    Robert Griesemer . resolved

    please use capital letters for type names and type parameters

    Mark Freeman

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Robert Griesemer
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I72644d7329c996eb1e67514063fe51c3ae06c38d
    Gerrit-Change-Number: 695977
    Gerrit-PatchSet: 36
    Gerrit-Owner: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Robert Griesemer <g...@google.com>
    Gerrit-CC: Robert Findley <rfin...@google.com>
    Gerrit-Attention: Robert Griesemer <g...@google.com>
    Gerrit-Comment-Date: Tue, 14 Oct 2025 22:34:08 +0000
    unsatisfied_requirement
    open
    diffy

    Mark Freeman (Gerrit)

    unread,
    Oct 14, 2025, 6:38:11 PM (yesterday) Oct 14
    to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
    Attention needed from Robert Griesemer

    Mark Freeman uploaded new patchset

    Mark Freeman uploaded patch set #37 to this change.
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Robert Griesemer
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: newpatchset
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I72644d7329c996eb1e67514063fe51c3ae06c38d
    Gerrit-Change-Number: 695977
    Gerrit-PatchSet: 37
    unsatisfied_requirement
    open
    diffy

    Robert Griesemer (Gerrit)

    unread,
    12:49 AM (23 hours ago) 12:49 AM
    to Mark Freeman, goph...@pubsubhelper.golang.org, Robert Findley, Go LUCI, golang-co...@googlegroups.com
    Attention needed from Mark Freeman

    Robert Griesemer added 5 comments

    Patchset-level comments
    File-level comment, Patchset 37 (Latest):
    Robert Griesemer . resolved

    Thanks.
    I will give this another thorough review, hopefully tomorrow.

    File src/cmd/compile/internal/types2/named.go
    Line 473, Patchset 32: t.fromRHS = underlying
    Robert Griesemer . resolved

    Is this necessary? What does it mean if underlying is not the real RHS?

    Mark Freeman

    IIRC, this `SetUnderlying` should ideally only be called for cases where we know the underlying type already, such as for importers and things in the universe.

    In that case, this just makes it follow the same flow as type checking from source — make a trivial RHS, resolve it, and set the underlying.

    Robert Griesemer

    ACK. Since we now have a clear separation between RHS and underlying, couldn't we keep RHS nil if it doesn't actually exist in the source? That is, for imported types and things in the universe?

    (I see that this would required changes to expndRHS below. Just trying to understand this code.)

    Mark Freeman

    We likely could for the cases you mentioned.

    It just seemed simpler to me to fold one case into the other to reduce the cases that the rest of the code must consider. For example, for imported types, it seemed natural to consider the underlying type from export data as the RHS and thus get the invariant that RHS cannot be nil (outside the cases where we allow it).

    Robert Griesemer

    Acknowledged.

    Line 555, Patchset 37 (Latest):func (n *Named) under() Type {
    Robert Griesemer . resolved

    Re: our conversation today:

    If we were following the RHS chain in a separate phase after the resolver and before we start type-checking objects, we could effectively move the work from this function out into that phase, I think.

    I wonder if this would simplify some of the surrounding code that depends on calling this function?

    (Perhaps for another CL.)

    Line 562, Patchset 37 (Latest): rhs := Type(n)
    Robert Griesemer . unresolved

    nitpick: I think
    ```
    var rhs Type = n
    ```
    is clearer because there's no need to think about what Type(n) does.

    Line 580, Patchset 37 (Latest):
    Robert Griesemer . unresolved

    nitpick: if you don't have an empty line after each case, I would not introduce empty lines within a case as it implies some kinds of break in the switch that doesn't exist

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Mark Freeman
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I72644d7329c996eb1e67514063fe51c3ae06c38d
    Gerrit-Change-Number: 695977
    Gerrit-PatchSet: 37
    Gerrit-Owner: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Robert Griesemer <g...@google.com>
    Gerrit-CC: Robert Findley <rfin...@google.com>
    Gerrit-Attention: Mark Freeman <markf...@google.com>
    Gerrit-Comment-Date: Wed, 15 Oct 2025 04:49:00 +0000
    unsatisfied_requirement
    open
    diffy

    Mark Freeman (Gerrit)

    unread,
    1:12 PM (11 hours ago) 1:12 PM
    to goph...@pubsubhelper.golang.org, Robert Findley, Robert Griesemer, Go LUCI, golang-co...@googlegroups.com
    Attention needed from Robert Griesemer

    Mark Freeman added 5 comments

    Commit Message
    Line 44, Patchset 33: type has been deduced. One can check if Named.underlying is
    a named type, but if the RHS was already a type literal, it's
    still ambiguous.
    Robert Griesemer . resolved

    I don't understand this 2nd sentence here: if the RHS is a type literal, then underlying would be that type literal eventually. And it is nil before. At least for a type definition.

    Mark Freeman

    This refers to Named.underlying as it was previously used — not with this change. As in, suppose `type B int`, even without calling `under`, `Named.underlying` would already be `int`.

    Robert Griesemer

    I see. I was confused because `int` in this case is not a type literal. It is a named, albeit predeclared, type.

    Mark Freeman

    Correct, pardon the inaccuracy in wording — adjusted.

    File src/cmd/compile/internal/types2/named.go
    Line 147, Patchset 33: unresolved namedState = iota // type parameters, RHS, and methods might be unavailable
    Robert Griesemer . resolved

    ... RHS, underlying, and methods ...

    (?) or, depending on my comment below (line 473), maybe just:

    ... underlying, and methods ...

    (?)

    Mark Freeman

    I believe the first is more correct. Unresolved instance and loaded types also do not have an RHS until `Named.resolve`.

    Robert Griesemer . resolved

    nitpick: I think
    ```
    var rhs Type = n
    ```
    is clearer because there's no need to think about what Type(n) does.

    Mark Freeman

    Done

    Robert Griesemer . resolved

    nitpick: if you don't have an empty line after each case, I would not introduce empty lines within a case as it implies some kinds of break in the switch that doesn't exist

    Mark Freeman

    Done

    File src/cmd/compile/internal/types2/universe.go
    Line 131, Patchset 33: typ.fromRHS = ityp
    Robert Griesemer . unresolved

    Again, I wonder if we can avoid this since there's no real RHS

    Mark Freeman

    We might be able to do that via something similar to `Named.inst` and `Named.loader`, which also describe how the details should be filled in.

    Perhaps a `Named.predeclared` to hold information for predeclared types until `resolve`?

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Robert Griesemer
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I72644d7329c996eb1e67514063fe51c3ae06c38d
    Gerrit-Change-Number: 695977
    Gerrit-PatchSet: 37
    Gerrit-Owner: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Robert Griesemer <g...@google.com>
    Gerrit-CC: Robert Findley <rfin...@google.com>
    Gerrit-Attention: Robert Griesemer <g...@google.com>
    Gerrit-Comment-Date: Wed, 15 Oct 2025 17:12:40 +0000
    unsatisfied_requirement
    open
    diffy

    Mark Freeman (Gerrit)

    unread,
    3:38 PM (8 hours ago) 3:38 PM
    to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
    Attention needed from Robert Griesemer

    Mark Freeman uploaded new patchset

    Mark Freeman uploaded patch set #38 to this change.
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Robert Griesemer
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: newpatchset
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I72644d7329c996eb1e67514063fe51c3ae06c38d
    Gerrit-Change-Number: 695977
    Gerrit-PatchSet: 38
    unsatisfied_requirement
    open
    diffy

    Mark Freeman (Gerrit)

    unread,
    3:40 PM (8 hours ago) 3:40 PM
    to goph...@pubsubhelper.golang.org, Robert Findley, Robert Griesemer, Go LUCI, golang-co...@googlegroups.com
    Attention needed from Robert Griesemer

    Mark Freeman added 1 comment

    File src/cmd/compile/internal/types2/decl.go
    Line 555, Patchset 33: // The RHS of a named can be nil if there's a cycle of non-reified aliases. There is likely a
    Robert Griesemer . resolved

    This is the first use of reify in this code base. It's not defined what it means. Also this comment applies to the next line.

    Can you add a simple example to clarify this?

    Mark Freeman

    Reworded, shifted, and added example

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Robert Griesemer
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I72644d7329c996eb1e67514063fe51c3ae06c38d
    Gerrit-Change-Number: 695977
    Gerrit-PatchSet: 38
    Gerrit-Owner: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Robert Griesemer <g...@google.com>
    Gerrit-CC: Robert Findley <rfin...@google.com>
    Gerrit-Attention: Robert Griesemer <g...@google.com>
    Gerrit-Comment-Date: Wed, 15 Oct 2025 19:40:41 +0000
    unsatisfied_requirement
    open
    diffy

    Mark Freeman (Gerrit)

    unread,
    3:56 PM (8 hours ago) 3:56 PM
    to goph...@pubsubhelper.golang.org, Robert Findley, Robert Griesemer, Go LUCI, golang-co...@googlegroups.com
    Attention needed from Robert Griesemer

    Mark Freeman added 1 comment

    File src/cmd/compile/internal/types2/named.go
    Robert Griesemer . unresolved

    we can fall through here, can't we?

    Mark Freeman

    I think we can only fall through if we say `rhs = iface`, but that seems mostly the same as returning here. No strong preference.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Robert Griesemer
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I72644d7329c996eb1e67514063fe51c3ae06c38d
    Gerrit-Change-Number: 695977
    Gerrit-PatchSet: 38
    Gerrit-Owner: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Robert Griesemer <g...@google.com>
    Gerrit-CC: Robert Findley <rfin...@google.com>
    Gerrit-Attention: Robert Griesemer <g...@google.com>
    Gerrit-Comment-Date: Wed, 15 Oct 2025 19:56:46 +0000
    unsatisfied_requirement
    open
    diffy

    Mark Freeman (Gerrit)

    unread,
    4:04 PM (8 hours ago) 4:04 PM
    to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
    Attention needed from Robert Griesemer

    Mark Freeman uploaded new patchset

    Mark Freeman uploaded patch set #39 to this change.
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Robert Griesemer
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: newpatchset
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I72644d7329c996eb1e67514063fe51c3ae06c38d
    Gerrit-Change-Number: 695977
    Gerrit-PatchSet: 39
    unsatisfied_requirement
    open
    diffy

    Robert Griesemer (Gerrit)

    unread,
    6:19 PM (6 hours ago) 6:19 PM
    to Mark Freeman, goph...@pubsubhelper.golang.org, Robert Findley, Go LUCI, golang-co...@googlegroups.com
    Attention needed from Robert Griesemer

    Robert Griesemer voted and added 14 comments

    Votes added by Robert Griesemer

    Code-Review+2

    14 comments

    Patchset-level comments
    File-level comment, Patchset 37:
    Robert Griesemer . resolved

    LGTM with the notes per discussion. Thanks!

    File src/cmd/compile/internal/types2/decl.go
    Line 476, Patchset 37: u, _ := named.resolve().under().(*Interface)
    Robert Griesemer . unresolved

    just: named.Underlying().(*Interface) ?

    File src/cmd/compile/internal/types2/named.go
    Line 147, Patchset 33: unresolved namedState = iota // type parameters, RHS, and methods might be unavailable
    Robert Griesemer . resolved

    ... RHS, underlying, and methods ...

    (?) or, depending on my comment below (line 473), maybe just:

    ... underlying, and methods ...

    (?)

    Robert Griesemer

    Done

    Line 249, Patchset 33: assert(n.underlying == nil) // underlying comes after resolving
    Robert Griesemer . resolved

    I don't understand this: aren't we past resolving (we set the state to complete in the next instruction)

    Mark Freeman

    I think complete is mostly orthogonal to N.underlying. We are still in N.resolve and so we cannot have called N.under.

    Robert Griesemer

    Acknowledged

    Line 311, Patchset 37: n.resolve().under()
    Robert Griesemer . resolved

    n.Underlying()

    Line 562, Patchset 37: rhs := Type(n)
    Robert Griesemer . resolved

    nitpick: I think
    ```
    var rhs Type = n
    ```
    is clearer because there's no need to think about what Type(n) does.

    Robert Griesemer

    Done

    Robert Griesemer . resolved

    nitpick: if you don't have an empty line after each case, I would not introduce empty lines within a case as it implies some kinds of break in the switch that doesn't exist

    Robert Griesemer

    Done

    Robert Griesemer . resolved

    we can fall through here, can't we?

    Robert Griesemer

    Done

    File src/cmd/compile/internal/types2/signature.go
    Line 442, Patchset 37: switch u := T.resolve().under().(type) {
    Robert Griesemer . unresolved

    T.Underlying()

    File src/cmd/compile/internal/types2/typestring.go
    Line 222, Patchset 37: if t == asNamed(universeComparable.Type()).resolve().under() {
    Robert Griesemer . unresolved

    I think this is not needed for this CL

    File src/cmd/compile/internal/types2/under.go
    Line 14, Patchset 37: if t := asNamed(t); t != nil {
    return t.resolve().under()
    }
    Robert Griesemer . unresolved

    get rid of the if fowr now - remove under() in a 2nd CL

    File src/cmd/compile/internal/types2/unify.go
    Line 342, Patchset 37: y = ny.resolve().under()
    Robert Griesemer . unresolved

    ny.Underlying()

    File src/cmd/compile/internal/types2/universe.go
    Line 131, Patchset 33: typ.fromRHS = ityp
    Robert Griesemer . resolved

    Again, I wonder if we can avoid this since there's no real RHS

    Robert Griesemer

    In another CL we may want to keep fromRHS nil if there's no actual source RHS.

    Line 146, Patchset 37: typ.resolve().under()
    Robert Griesemer . unresolved

    typ.Underlying()

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Robert Griesemer
    Submit Requirements:
    • requirement satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I72644d7329c996eb1e67514063fe51c3ae06c38d
    Gerrit-Change-Number: 695977
    Gerrit-PatchSet: 37
    Gerrit-Owner: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Robert Griesemer <g...@google.com>
    Gerrit-CC: Robert Findley <rfin...@google.com>
    Gerrit-Attention: Robert Griesemer <g...@google.com>
    Gerrit-Comment-Date: Wed, 15 Oct 2025 22:18:58 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Robert Griesemer (Gerrit)

    unread,
    6:51 PM (5 hours ago) 6:51 PM
    to Mark Freeman, goph...@pubsubhelper.golang.org, Robert Findley, Go LUCI, golang-co...@googlegroups.com
    Attention needed from Mark Freeman

    Robert Griesemer voted and added 6 comments

    Votes added by Robert Griesemer

    Code-Review+2

    6 comments

    Patchset-level comments
    File-level comment, Patchset 39 (Latest):
    Robert Griesemer . resolved

    Please also make the following adjustments before submitting. Thanks!

    Commit Message
    Line 7, Patchset 39 (Latest):go/types, types2: change and enforce lifecycle of named types
    Robert Griesemer . unresolved

    maybe:

    change and enforce lifecycle of Names.fromRHS and Named.underlying fields

    (you don't really change the lifecycle of Named types)

    Line 39, Patchset 39 (Latest):While this approach works, it introduces some caveats:
    Robert Griesemer . unresolved

    s/some caveats/problems/

    Line 48, Patchset 39 (Latest):Operations derived from Named.underlying share similar caveats. For
    Robert Griesemer . unresolved

    s/share similar caveats/have similar problems/

    Line 73, Patchset 33:is exploited by a test (issue61678.go) in x/tools.
    Robert Griesemer . resolved

    So what is the action Here?

    Mark Freeman

    No action, we dropped the test for 1.26 via go.dev/cl/700395.

    Robert Griesemer

    Done

    File src/internal/types/testdata/fixedbugs/issue75194.go
    Line 1, Patchset 39 (Latest):package p
    Robert Griesemer . unresolved

    Please add the usual copyright notice here.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Mark Freeman
    Submit Requirements:
    • requirement satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I72644d7329c996eb1e67514063fe51c3ae06c38d
    Gerrit-Change-Number: 695977
    Gerrit-PatchSet: 39
    Gerrit-Owner: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Mark Freeman <markf...@google.com>
    Gerrit-Reviewer: Robert Griesemer <g...@google.com>
    Gerrit-CC: Robert Findley <rfin...@google.com>
    Gerrit-Attention: Mark Freeman <markf...@google.com>
    Gerrit-Comment-Date: Wed, 15 Oct 2025 22:51:11 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages