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

bug: golang fixedbugs/issue23017.go #18

Closed
visualfc opened this issue Jan 30, 2022 · 2 comments
Closed

bug: golang fixedbugs/issue23017.go #18

visualfc opened this issue Jan 30, 2022 · 2 comments

Comments

@visualfc
Copy link
Member

package main

import (
	"fmt"
)

func main() {
	type P struct{ i int }
	var m = map[int]int{}
	var p *P

	defer func() {
		recover()
		check(1, len(m))
		check(3, m[2])
	}()
	m[2], p.i = 3, 2
}

func check(want, got int) {
	if want != got {
		panic(fmt.Sprintf("wanted %d, but got %d", want, got))
	}
}
@visualfc
Copy link
Member Author

ctx.BuilderMode = ssa.PrintFunctions

# Name: main.main
# Package: main
# Location: ./issue23017.go:17:6
func main():
0:                                                                entry P:0 S:0
	t0 = make map[int]int 0:int                                 map[int]int
	t1 = &nil:*P.i [#0]                                                *int
	t0[2:int] = 3:int
	*t1 = 2:int
	return

# Name: main.check
# Package: main
# Location: ./issue23017.go:32:6
func check(want int, got int):
0:                                                                entry P:0 S:2
	t0 = want != got                                                   bool
	if t0 goto 1 else 2
1:                                                              if.then P:1 S:0
	t1 = new [2]interface{} (varargs)                       *[2]interface{}
	t2 = &t1[0:int]                                            *interface{}
	t3 = make interface{} <- int (want)                         interface{}
	*t2 = t3
	t4 = &t1[1:int]                                            *interface{}
	t5 = make interface{} <- int (got)                          interface{}
	*t4 = t5
	t6 = slice t1[:]                                          []interface{}
	t7 = fmt.Sprintf("wanted %d, but go...":string, t6...)           string
	t8 = make interface{} <- string (t7)                        interface{}
	panic t8
2:                                                              if.done P:1 S:0
	return

# Name: main.init
# Package: main
# Synthetic: package initializer
func init():
0:                                                                entry P:0 S:2
	t0 = *init$guard                                                   bool
	if t0 goto 2 else 1
1:                                                           init.start P:1 S:1
	*init$guard = true:bool
	t1 = fmt.init()                                                      ()
	jump 2
2:                                                            init.done P:2 S:0
	return

@visualfc
Copy link
Member Author

fixed by golang.org/x/tools

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant