Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
cherrymui opened this issue Oct 15, 2019 · 1 comment
Closed

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

cherrymui opened this issue Oct 15, 2019 · 1 comment

Comments

@cherrymui
Copy link
Contributor

@cherrymui cherrymui commented Oct 15, 2019

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

@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Oct 15, 2019

Change https://golang.org/cl/201297 mentions this issue: cmd/compile: on Wasm and AIX, let deferred nil function panic at invocation

@gopherbot gopherbot closed this in c4817f5 Oct 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.