-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Open
Labels
NeedsInvestigationSomeone 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.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Milestone
Description
Go version
go version go1.22.0 linux/amd64
Output of go env in your module/workspace:
.What did you do?
package main
import (
"fmt"
"strings"
)
func foo() string {
for b, i := (strings.Builder{}), byte('a'); ; i++ {
b.WriteByte(i)
if i == 'z' {
return b.String()
}
}
}
func bar(callback func(*strings.Builder)) string {
for b, i := (strings.Builder{}), byte('a'); ; i++ {
b.WriteByte(i)
callback(&b) // <-- difference here
if i == 'z' {
return b.String()
}
}
}
func main() {
debugProcess := func(pb *strings.Builder) {
// do nothing
}
fmt.Println("foo:", foo())
fmt.Println("bar:", bar(debugProcess))
}What did you see happen?
Consistent behavior between foo and bar with 1.22 compiler.
What did you expect to see?
Inconsistent behavior between foo and bar with 1.22 compiler.
Metadata
Metadata
Assignees
Labels
NeedsInvestigationSomeone 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.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Type
Projects
Status
In Progress