Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify custom types support #2006

Closed
x1unix opened this issue Apr 30, 2024 · 1 comment
Closed

Clarify custom types support #2006

x1unix opened this issue Apr 30, 2024 · 1 comment
Assignees
Labels
🐞 bug Something isn't working 📦 🤖 gnovm Issues or PRs gnovm related

Comments

@x1unix
Copy link

x1unix commented Apr 30, 2024

Description

In Go language, user is able to define a custom type on top of a built-in type.

For example:

type Set map[string]struct{}

func NewSet(items ...string) Set {
   ...
}

func (s Set) Has(key string) bool {
  _, ok := s[key]
 return ok
}

When I'm trying to use the same type, I get a following error:

Snippet

recovered: interface conversion: gnolang.Type is *gnolang.DeclaredType, not *gnolang.MapType
stack:
goroutine 60 [running]:
runtime/debug.Stack()
	/usr/local/go/src/runtime/debug/stack.go:24 +0x65
github.com/gnolang/gno/pkgs/sdk.(*BaseApp).runTx.func1()
	/opt/build/pkgs/sdk/baseapp.go:743 +0x2cd
panic({0xc60820, 0xc014450700})
	/usr/local/go/src/runtime/panic.go:884 +0x212

...

The same code but without custom map type works.

Looks like, Gno doesn't support this kind of stuff. I checked Go and Gno compat guide but it didn't mention this limitation.

Can you please update the compat doc?

@deelawn
Copy link
Contributor

deelawn commented May 2, 2024

The problem mentioned here will be fixed by #1246

@Kouteki Kouteki moved this from Triage to In Progress in 🧙‍♂️gno.land core team May 10, 2024
@linear linear bot removed 🐞 bug Something isn't working 📦 🤖 gnovm Issues or PRs gnovm related labels Sep 11, 2024
@Kouteki Kouteki closed this as completed Nov 17, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in 🧙‍♂️gno.land core team Nov 17, 2024
@Kouteki Kouteki added 🐞 bug Something isn't working 📦 🤖 gnovm Issues or PRs gnovm related labels Nov 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working 📦 🤖 gnovm Issues or PRs gnovm related
Projects
Development

Successfully merging a pull request may close this issue.

3 participants