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

[BUG] Trait inheritance not recognized in variadic contexts #3928

Open
jjvraw opened this issue Jan 6, 2025 · 0 comments
Open

[BUG] Trait inheritance not recognized in variadic contexts #3928

jjvraw opened this issue Jan 6, 2025 · 0 comments
Labels
bug Something isn't working mojo-repo Tag all issues with this label

Comments

@jjvraw
Copy link
Contributor

jjvraw commented Jan 6, 2025

Bug description

The type system fails to recognise trait inheritance when used in variadic contexts.

Steps to reproduce

1. Variadic Type Parameters with Collections

trait SomeTrait(CollectionElement):
    ...

struct SomeStruct1[*Ts: CollectionElement]:  # Works
    var tuple: Tuple[*Ts]

struct SomeStruct2[T: SomeTrait]:  # Works
    var tuple: Tuple[T]

struct SomeStruct3[*Ts: SomeTrait]:  # Fails
    var tuple: Tuple[*Ts]

Error: Tuple parameter #0 has `Variadic[CollectionElement]` type, but value has type `Variadic[SomeTrait]`

2. Variadic Keyword Arguments

fn test3(**kwargs: SomeTrait) raises:  # Fails
    pass

Error: argument type must conform to `CollectionElement` to be used in keyword variadic argument

System information

- Ubuntu 24.04
- mojo 24.6.0.dev2024120105 (78dab9b8)
- magic 0.5.1 - (based on pixi 0.37.0)
@jjvraw jjvraw added bug Something isn't working mojo-repo Tag all issues with this label labels Jan 6, 2025
@jjvraw jjvraw changed the title [BUG] Fail to recognise trait inheritance in variadic type parameters [BUG] Trait inheritance not recognized in variadic contexts Jan 10, 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 mojo-repo Tag all issues with this label
Projects
None yet
Development

No branches or pull requests

1 participant