From c82e64637c4d8a1448500faddaceea672cddecf6 Mon Sep 17 00:00:00 2001 From: Morgan Date: Tue, 3 Sep 2024 12:32:32 +0200 Subject: [PATCH] chore: remove panic from uverse (#2626) This function in uverse is misleading, because it's never actually called. Panics are converted to a `*PanicStmt`, not as function calls.
Contributors' checklist... - [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).
--- gnovm/pkg/gnolang/misc.go | 4 ++++ gnovm/pkg/gnolang/uverse.go | 12 +----------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/gnovm/pkg/gnolang/misc.go b/gnovm/pkg/gnolang/misc.go index a05de8c74aa..7f7ce0b3a87 100644 --- a/gnovm/pkg/gnolang/misc.go +++ b/gnovm/pkg/gnolang/misc.go @@ -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 { diff --git a/gnovm/pkg/gnolang/uverse.go b/gnovm/pkg/gnolang/uverse.go index 880a75396ca..38ccdddea85 100644 --- a/gnovm/pkg/gnolang/uverse.go +++ b/gnovm/pkg/gnolang/uverse.go @@ -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]