Skip to content

cmd/compile: deferring nil function panicked too early on Wasm and AIX #34926

@cherrymui

Description

@cherrymui

What version of Go are you using (go version)?

tip (06b12e6)

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

js/wasm, and aix/ppc64

What did you do?

https://play.golang.org/p/6zD83-Dhd1P

package main

var x = 0

func main() {
	defer func() { recover(); println(x) }()
	f()
}

func f() {
	var nilf func()
	defer nilf()
	x = 1
}

What did you expect to see?

The spec requires (https://golang.org/ref/spec#Defer_statements)

If a deferred function value evaluates to nil, execution panics when the function is invoked, not when the "defer" statement is executed.

So in the program above, the assignment x=1 should go through, so it should print 1.

What did you see instead?

Print 0 on Wasm and AIX.

I'll send a CL shortly.

cc @danscales

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.OS-AIXarch-wasmWebAssembly issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions