Skip to content

runtime: recover calls in loop body of ranging over iterators doesn't take effect #71685

@zigo101

Description

@zigo101

Go version

go version go1.24.0 linux/amd64

Output of go env in your module/workspace:

.

What did you do?

package main

import "fmt"

func main() {
	defer foo()
	panic(123)
}

func foo() {
	for i := range iter {
		fmt.Println(i, recover()) // 0 <nil>
	}
}

func iter(yield func(int) bool) {
	yield(0)
}

What did you see happen?

0 <nil>
panic: 123

goroutine 1 [running]:
main.main()

What did you expect to see?

0 123

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.NeedsInvestigationSomeone 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.

    Type

    No type

    Projects

    Status

    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions