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

panic: unreachable: 20(*types.Struct) when returns closure in closure #864

Open
cpunion opened this issue Nov 12, 2024 · 0 comments · May be fixed by #874
Open

panic: unreachable: 20(*types.Struct) when returns closure in closure #864

cpunion opened this issue Nov 12, 2024 · 0 comments · May be fixed by #874

Comments

@cpunion
Copy link
Contributor

cpunion commented Nov 12, 2024

package main

func main() {
	x := 1
	f := func(i int) func(int) {
		return func(i int) {
			println("closure", i, x)
		}
	}
	f(1)(2)
}

Compile:

go run ./cmd/llgo run ./a.go
2024/11/12 11:07:35 unreachable: 20(*types.Struct)
panic: unreachable: 20(*types.Struct)


goroutine 1 [running]:
log.Panicf({0x104dc64db?, 0x104eb24a0?}, {0x14004bbef98?, 0x14001788c80?, 0x10c8fd518?})
	/Users/lijie/.version-fox/temp/1730649600-834/golang/src/log/log.go:391 +0x68
github.com/goplus/llgo/ssa.(*aBuilder).Call(0x14001788c80, {{0x1?}, 0x14002229f80?}, {0x140014499f0, 0x1, 0x1})
	/Users/lijie/source/goplus/llgo/ssa/expr.go:985 +0x190
github.com/goplus/llgo/ssa.(*aBuilder).Do(0x1400142c8f0?, 0x10ca2fba8?, {{0x14000d89020?}, 0x14002229f80?}, {0x140014499f0?, 0x0?, 0x14001f423f0?})
	/Users/lijie/source/goplus/llgo/ssa/expr.go:1024 +0x78
github.com/goplus/llgo/cl.(*context).call(0x1400142c8f0, 0x14001788c80, 0x14002229d00?, 0x1400132a8c0)
	/Users/lijie/source/goplus/llgo/cl/instr.go:416 +0x788
github.com/goplus/llgo/cl.(*context).compileInstrOrValue(0x1400142c8f0, 0x14001788c80, {0x104ee7c58?, 0x1400132a880?}, 0x40?)
	/Users/lijie/source/goplus/llgo/cl/compile.go:534 +0x104
github.com/goplus/llgo/cl.(*context).compileInstr(0x1400142c8f0, 0x14001f1d290?, {0x104ee5898?, 0x1400132a880?})
	/Users/lijie/source/goplus/llgo/cl/compile.go:709 +0x638
github.com/goplus/llgo/cl.(*context).compileBlock(0x1400142c8f0, 0x14001788c80, 0x14001b6f970, 0x0, 0x1, 0x0)
	/Users/lijie/source/goplus/llgo/cl/compile.go:390 +0x414
github.com/goplus/llgo/cl.(*context).compileFuncDecl.func1()
	/Users/lijie/source/goplus/llgo/cl/compile.go:281 +0x404
github.com/goplus/llgo/cl.NewPackageEx(0x14000204000, 0x14001f01890, 0x14000d44000, {0x140002821a8, 0x1, 0x1})
	/Users/lijie/source/goplus/llgo/cl/compile.go:956 +0x6b8
github.com/goplus/llgo/internal/build.buildPkg(0x14002397560, 0x14002229860, 0x0)
	/Users/lijie/source/goplus/llgo/internal/build/build.go:506 +0x2bc
github.com/goplus/llgo/internal/build.buildAllPkgs(0x14002397560, {0x140002822b0?, 0x14000030600?, 0x104dbf764?}, 0x0?)
	/Users/lijie/source/goplus/llgo/internal/build/build.go:340 +0x360
github.com/goplus/llgo/internal/build.Do({0x1400019c1a0?, 0x1?, 0x1?}, 0x140001b85a0)
	/Users/lijie/source/goplus/llgo/internal/build/build.go:205 +0xa6c
github.com/goplus/llgo/cmd/internal/run.runCmdEx(0x104dd2085?, {0x1400019c1a0, 0x1, 0x1}, 0x2)
	/Users/lijie/source/goplus/llgo/cmd/internal/run/run.go:66 +0x12c
github.com/goplus/llgo/cmd/internal/run.runCmd(0x140001b8120?, {0x1400019c1a0?, 0x140000566e8?, 0x104b00794?})
	/Users/lijie/source/goplus/llgo/cmd/internal/run/run.go:50 +0x24
main.main()
	/Users/lijie/source/goplus/llgo/cmd/llgo/llgo.go:90 +0x4c8
exit status 2
@cpunion cpunion linked a pull request Nov 24, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant