From cb97748596d6bf3968c1f9b50eaa6444ea3f5e5e Mon Sep 17 00:00:00 2001 From: Lee ByeongJun Date: Sat, 18 Nov 2023 01:04:54 +0900 Subject: [PATCH] print some recover message --- gnovm/pkg/gnolang/uverse.go | 22 +++++++++++++--------- gnovm/pkg/gnolang/uverse_test.go | 6 +++--- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/gnovm/pkg/gnolang/uverse.go b/gnovm/pkg/gnolang/uverse.go index 44f1c3d811b..bf98a1965ce 100644 --- a/gnovm/pkg/gnolang/uverse.go +++ b/gnovm/pkg/gnolang/uverse.go @@ -945,17 +945,21 @@ func UverseNode() *PackageNode { for i := 0; i < xvl; i++ { ev := xv.TV.GetPointerAtIndexInt(m.Store, i).Deref() // TODO: Generalize this to all types. - if ev.T.Kind() == SliceKind || ev.T.Kind() == StringKind { - if ev.V == nil { - ss[i] = "undefined" - } else { - ss[i] = ev.Sprint(m) - } + if ev.T.Kind() == FuncKind { + ss[i] = ev.T.String() } else { - if ev.T == nil { - ss[i] = "undefined" + if ev.T.Kind() == SliceKind || ev.T.Kind() == StringKind { + if ev.V == nil { + ss[i] = "undefined" + } else { + ss[i] = ev.Sprint(m) + } } else { - ss[i] = ev.Sprint(m) + if ev.T == nil { + ss[i] = "undefined" + } else { + ss[i] = ev.Sprint(m) + } } } } diff --git a/gnovm/pkg/gnolang/uverse_test.go b/gnovm/pkg/gnolang/uverse_test.go index 485a6b93e84..15fddf2112e 100644 --- a/gnovm/pkg/gnolang/uverse_test.go +++ b/gnovm/pkg/gnolang/uverse_test.go @@ -68,7 +68,7 @@ func TestSimpleRecover(t *testing.T) { m.RunFiles(n) m.RunMain() - assertOutput(t, c, "recover simple panic\n") + assertOutput(t, c, "simple panic\nrecover\n") } // TODO: Resolve runtime error @@ -104,7 +104,7 @@ func TestNestedRecover(t *testing.T) { func main() { defer func() { println("outer recover", recover()) }() - defer func() { panic("nested panic") }() + defer func() { println("nested panic") }() println("simple panic") }` @@ -112,5 +112,5 @@ func TestNestedRecover(t *testing.T) { m.RunFiles(n) m.RunMain() - assertOutput(t, c, "outer recover nested panic\n") + assertOutput(t, c, "simple panic\nnested panic\nouter recover\n") }