Skip to content

Missing Error for interface{} to int Conversion #3412

Closed
@omarsy

Description

@omarsy

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

Metadata

Metadata

Labels

📦 🤖 gnovmIssues or PRs gnovm related🐞 bugSomething isn't working

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions