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

TinyGo Panics on Generic Type Aliases #4819

Open
Yeaseen opened this issue Mar 19, 2025 · 2 comments
Open

TinyGo Panics on Generic Type Aliases #4819

Yeaseen opened this issue Mar 19, 2025 · 2 comments

Comments

@Yeaseen
Copy link

Yeaseen commented Mar 19, 2025

TinyGo crashes when compiling a generic type alias, even when using GODEBUG=gotypesalias=1. Though I am not sure whether TinyGo supports generic type aliases correctly.

$ cat test.go
package main
import "fmt"
// Define a generic type
type Wrapper[T any] struct {
	Value T
}
// Alias declaration with type parameter
type Alias[T any] = Wrapper[T]

func main() {
	// Using the alias
	var a Alias[int] = Alias[int]{Value: 42}
	fmt.Println("a:", a.Value)
}
GODEBUG=gotypesalias=1 tinygo run test.go
panic: unknown type: main.Alias[int]

goroutine 200 [running]:
github.com/tinygo-org/tinygo/compiler.(*compilerContext).makeLLVMType(0xc003bb2000?, {0x7020428?, 0xc00287d340?})
        /__w/tinygo/tinygo/compiler/compiler.go:468 +0x539
@gandarez
Copy link

gandarez commented Mar 20, 2025

It produces different errors when setting target.

Without target set

GODEBUG=gotypesalias=1 tinygo run main.go

panic: unknown type: sync.Mutex

goroutine 54 [running]:
github.com/tinygo-org/tinygo/compiler.(*compilerContext).makeLLVMType(0x14001ca8000?, {0x10aa97468?, 0x1400587a800?})
        /Users/runner/work/tinygo/tinygo/compiler/compiler.go:468 +0x578

With pico2-w target set

GODEBUG=gotypesalias=1 tinygo run -target=pico2-w main.go

panic: unknown type: any

goroutine 116 [running]:
github.com/tinygo-org/tinygo/compiler.(*compilerContext).makeLLVMType(0x1400af8a280?, {0x10b4ab468?, 0x140000221c0?})
        /Users/runner/work/tinygo/tinygo/compiler/compiler.go:468 +0x578

Even though changing it from any to int return the same result panic: unknown type: any.

@eliasnaur
Copy link
Contributor

Probable dupe: #4416

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants