Skip to content

Commit

Permalink
fix(gnovm): repair selector type aliasing (gnolang#2483)
Browse files Browse the repository at this point in the history
Closes gnolang#2479.

When defining a type alias to a type in another package, the existing
type is specified with a selector expression. This PR ensures that the
underlying type being aliased is properly extracted.

<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>

Co-authored-by: Manfred Touron <94029+moul@users.noreply.github.com>
  • Loading branch information
2 people authored and gfanton committed Jul 23, 2024
1 parent 2d6ed7d commit 899cf32
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gnovm/pkg/gnolang/preprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -3343,7 +3343,7 @@ func tryPredefine(store Store, last BlockNode, d Decl) (un Name) {
pn := pv.GetPackageNode(store)
tx.Path = pn.GetPathForName(store, tx.Sel)
ptr := pv.GetBlock(store).GetPointerTo(store, tx.Path)
t = ptr.TV.T
t = ptr.TV.GetType()
default:
panic(fmt.Sprintf(
"unexpected type declaration type %v",
Expand Down
12 changes: 12 additions & 0 deletions gnovm/tests/files/type_alias.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// PKGPATH: gno.land/r/type_alias_test
package type_alias_test

import "gno.land/p/demo/uassert"

type TestingT = uassert.TestingT

func main() {
println(TestingT)
}

// No need for output; not panicking is passing.

0 comments on commit 899cf32

Please sign in to comment.