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

Missing Error for interface{} to int Conversion #3412

Open
omarsy opened this issue Dec 27, 2024 · 1 comment · May be fixed by #3757
Open

Missing Error for interface{} to int Conversion #3412

omarsy opened this issue Dec 27, 2024 · 1 comment · May be fixed by #3757
Assignees
Labels
🐞 bug Something isn't working 📦 🤖 gnovm Issues or PRs gnovm related

Comments

@omarsy
Copy link
Member

omarsy commented Dec 27, 2024

Description

The following code compiles and runs successfully in Gno, but it should not. Instead, it should return a compilation error indicating that a type assertion is required when converting an interface{} to a concrete type.

package main

func main() {
	var t interface{}
	t = 2
	var g = int(t)
	println(g)
}

Expected Behavior

The code should fail to compile and return an error similar to:

cannot convert t (variable of type interface{}) to type int: need type assertion

This is the expected behavior in Go, as direct type conversion from an interface{} to a concrete type without a type assertion is not allowed.

Actual Behavior

In Gno, the code compiles and executes successfully, producing the output:

2
@odeke-em
Copy link
Contributor

If I modify the value assigned to t to “23”, I get a cryptic runtime crash at runtime https://play.gno.land/p/WXhnfs8M2wr

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
Status: In Review
Development

Successfully merging a pull request may close this issue.

8 participants