mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-03 02:27:48 +00:00
tgo: Print IR on panic (sometimes)
This commit is contained in:
@@ -1601,10 +1601,16 @@ func Compile(pkgName, runtimePath, outpath, target string, printIR bool) error {
|
||||
}
|
||||
|
||||
// Compile Go code to IR.
|
||||
parseErr := c.Parse(pkgName, buildTags)
|
||||
if printIR {
|
||||
fmt.Println(c.IR())
|
||||
}
|
||||
parseErr := func() error {
|
||||
if printIR {
|
||||
// Run this even if c.Parse() panics.
|
||||
defer func() {
|
||||
fmt.Println("IR until the error:")
|
||||
fmt.Println(c.IR())
|
||||
}()
|
||||
}
|
||||
return c.Parse(pkgName, buildTags)
|
||||
}()
|
||||
if parseErr != nil {
|
||||
return parseErr
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user