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
Labels
arch-wasm WebAssembly issues FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. OS-AIX

Comments

@cherrymui
Copy link
Member

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

@dmitshur dmitshur added arch-wasm WebAssembly issues OS-AIX NeedsFix The path to resolution is known, but the work has not been done. labels Oct 15, 2019
@gopherbot
Copy link

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

@golang golang locked and limited conversation to collaborators Oct 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly issues FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. OS-AIX
Projects
None yet
Development

No branches or pull requests

3 participants