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

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

Clarify custom types support #2006

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

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 deelawn added 🐞 bug Something isn't working 📦 🤖 gnovm Issues or PRs gnovm related labels May 1, 2024
@deelawn deelawn self-assigned this May 1, 2024
@deelawn
Copy link
Contributor

deelawn commented May 2, 2024

The problem mentioned here will be fixed by #1246

@linear linear bot removed 🐞 bug Something isn't working 📦 🤖 gnovm Issues or PRs gnovm related labels Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

2 participants