You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Go2hx fails to translate Go code that uses generic functions with type parameters. When attempting to compile a program that uses generics, Go2hx produces an error indicating that the generic type cannot be found. Below is an example of code that works correctly in Go but fails in Go2hx.
Source Go code:
package main
import"fmt"funcmain() {
f[int]()
}
funcf[Tany]() {
if []T(nil) !=nil {
fmt.Println("Slice is not nil")
} else {
fmt.Println("Slice is nil")
}
if (func() T)(nil) !=nil {
fmt.Println("Function is not nil")
} else {
fmt.Println("Function is nil")
}
}
_internal/Runner.macro.hx:16: character 35 : Type not found : T_
Comment:
The error indicates that Go2hx does not handle generic type parameters (T) correctly. When translating the Go function f[T any](), Go2hx seems unable to define or pass the generic type T to the Haxe equivalent, leading to a Type not found error. Simplifying the Go code to remove generics (i.e., by replacing T with a concrete type such as int) allows the translation to succeed, indicating the issue is specific to generics.
The text was updated successfully, but these errors were encountered:
Go2hx fails to translate Go code that uses generic functions with type parameters. When attempting to compile a program that uses generics, Go2hx produces an error indicating that the generic type cannot be found. Below is an example of code that works correctly in Go but fails in Go2hx.
Source Go code:
Expected Go Output:
Translated Haxe Code:
Error Message in Haxe:
Comment:
The error indicates that Go2hx does not handle generic type parameters (T) correctly. When translating the Go function
f[T any]()
, Go2hx seems unable to define or pass the generic type T to the Haxe equivalent, leading to a Type not found error. Simplifying the Go code to remove generics (i.e., by replacing T with a concrete type such as int) allows the translation to succeed, indicating the issue is specific to generics.The text was updated successfully, but these errors were encountered: