Closed
Description
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
Assignees
Type
Projects
Status
Done