Repository navigation
reflect: Type.CanSeq[2]: false positive for Seq-like function types with named bool type #77542
Description
Activity
- addedcompiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
on Feb 11, 2026 Related Issues
- reflect: Value.Seq panicking on iter.Seq2 #71913 (closed)
- reflect: Value.Seq panicking on functional iterator methods #71874 (closed)
- reflect: Value.Seq iteration value types not matching the type of given int types #71905 (closed)
- cmd/compile: range over func internal compiler error with named bool type in yield #71131 (closed)
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
- addedBugReportIssues describing a possible bug in the Go implementation.Issues describing a possible bug in the Go implementation.
on Feb 11, 2026 I agree this is a bug; range-over-func allows the func type to be named (e.g. iter.Seq) or unnamed, but the result of the yield function must be exactly the built-in
booltype and not a named boolean type.@golang/runtime
- addedNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
on Feb 11, 2026 I agree this is a bug; range-over-func allows the func type to be named (e.g. iter.Seq) or unnamed, but the result of the yield function must be exactly the built-in
booltype and not a named boolean type.For range-over-func even the yield function type can be named! It's only the boolean return type of the yield function that has to be precisely
bool.As it stands, you might argue that
Type.CanSeq[2]behaves correctly, becauseValue.Seq[2]succeeds whenType.CanSeq[2]returnstrue, even if the correspondingfor ... rangeloop fails to compile.Then again, perhaps this is in order, seeing as #71913 was closed (signifying it's not a bug that you can't use
Value.Seqon aValuecontaining aniter.Seq2, even though the language itself allowsfor foo := range seq2).for reference
that Type.CanSeq[2] behaves correctly, because Value.Seq[2] succeeds when Type.CanSeq[2] returns trueThat's what I thought when I sent CL 578815.
If is a bug,If modifications are needed, the relevant code can be found in
https://github.com/golang/go/blob/master/src/reflect/type.go#L944C1-L958C2
`Change https://go.dev/cl/745580 mentions this issue:
reflect: fix support for iter with named boolean in Seq/Seq2- addedFixPendingIssues that have a fix which has not yet been reviewed or submitted.Issues that have a fix which has not yet been reviewed or submitted.
on Feb 18, 2026 I agree that this is a bug as long as #71164 is not accepted.
- moved this from In Progress to Done in Go Compiler / Runtime / Command
on Feb 25, 2026 - added a commit that references this issue
on Feb 25, 2026
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Go version
go version go1.26.0 darwin/arm64
Output of
go envin your module/workspace:What did you do?
Ran the following:
What did you see happen?
CanSeqandCanSeq2both returntrue.What did you expect to see?
Trying to range over
fncurrently won't compile, so I would expectCanSeqandCanSeq2to reflect this and returnfalse.See issue #71164.