Skip to content

Commit

Permalink
chore: remove panic from uverse (gnolang#2626)
Browse files Browse the repository at this point in the history
This function in uverse is misleading, because it's never actually
called. Panics are converted to a `*PanicStmt`, not as function calls.

<details><summary>Contributors' checklist...</summary>

- [x] Added new tests, or not needed, or not feasible
- [x] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [x] Updated the official documentation or not needed
- [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [x] Added references to related issues and PRs
- [x] Provided any useful hints for running manual tests
- [x] Added new benchmarks to [generated
graphs](https://gnoland.github.io/benchmarks), if any. More info
[here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).
</details>
  • Loading branch information
thehowl committed Sep 3, 2024
1 parent 68ef445 commit c82e646
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
4 changes: 4 additions & 0 deletions gnovm/pkg/gnolang/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ func isReservedName(n Name) bool {

// scans uverse static node for blocknames. (slow)
func isUverseName(n Name) bool {
if n == "panic" {
// panic is not in uverse, as it is parsed as its own statement (PanicStmt)
return true
}
uverseNames := UverseNode().GetBlockNames()
for _, name := range uverseNames {
if name == n {
Expand Down
12 changes: 1 addition & 11 deletions gnovm/pkg/gnolang/uverse.go
Original file line number Diff line number Diff line change
Expand Up @@ -928,17 +928,7 @@ func UverseNode() *PackageNode {
return
},
)
defNative("panic",
Flds( // params
"err", AnyT(), // args[0]
),
nil, // results
func(m *Machine) {
arg0 := m.LastBlock().GetParams1()
xv := arg0.Deref()
panic(xv.Sprint(m))
},
)
// NOTE: panic is its own statement type, and is not defined as a function.
defNative("print",
Flds( // params
"xs", Vrd(AnyT()), // args[0]
Expand Down

0 comments on commit c82e646

Please sign in to comment.