Skip to content

Commit

Permalink
print some recover message
Browse files Browse the repository at this point in the history
  • Loading branch information
notJoon committed Nov 17, 2023
1 parent 2afabe0 commit cb97748
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
22 changes: 13 additions & 9 deletions gnovm/pkg/gnolang/uverse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions gnovm/pkg/gnolang/uverse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -104,13 +104,13 @@ 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")
}`

n := MustParseFile("main.go", c)
m.RunFiles(n)
m.RunMain()

assertOutput(t, c, "outer recover nested panic\n")
assertOutput(t, c, "simple panic\nnested panic\nouter recover\n")
}

0 comments on commit cb97748

Please sign in to comment.