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

Closed
omarsy opened this issue Dec 27, 2024 · 1 comment · Fixed by #3757
Closed

Missing Error for interface{} to int Conversion #3412

omarsy opened this issue Dec 27, 2024 · 1 comment · 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

@zivkovicmilos zivkovicmilos added the 📦 🤖 gnovm Issues or PRs gnovm related label Jan 6, 2025
@Kouteki Kouteki moved this from Triage to In Review in 🧙‍♂️gno.land core team Jan 6, 2025
@Kouteki Kouteki moved this from In Review to Todo in 🧙‍♂️gno.land core team Jan 6, 2025
@Kouteki Kouteki removed the in focus label Jan 6, 2025
@thehowl thehowl added this to the 🚀 Mainnet beta launch milestone Jan 23, 2025
@petar-dambovaliev petar-dambovaliev self-assigned this Feb 14, 2025
@petar-dambovaliev petar-dambovaliev moved this from Todo to In Progress in 🧙‍♂️gno.land core team Feb 14, 2025
@petar-dambovaliev petar-dambovaliev moved this from In Progress to In Review in 🧙‍♂️gno.land core team Feb 15, 2025
@Kouteki Kouteki moved this from In Review to In Progress in 🧙‍♂️gno.land core team Mar 2, 2025
@github-project-automation github-project-automation bot moved this from In Progress to Done in 🧙‍♂️gno.land core team Mar 9, 2025
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.

8 participants