goplus / igop

The Go/Go+ Interpreter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bug: golang fixedbugs/issue23017.go

visualfc opened this issue · comments

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))
	}
}

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

fixed by golang.org/x/tools