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 and static dispatch #4055

Open
thomas-huegel opened this issue Mar 5, 2025 · 0 comments
Open

[BUG] Trait inheritance and static dispatch #4055

thomas-huegel opened this issue Mar 5, 2025 · 0 comments
Labels
bug Something isn't working max-repo mojo Issues that are related to mojo

Comments

@thomas-huegel
Copy link

thomas-huegel commented Mar 5, 2025

Bug description

Compile error:

bug.mojo:14:34: error: no matching function in call to 'do_something'
    return do_something[T, "Hey"]()
           ~~~~~~~~~~~~~~~~~~~~~~^~
bug.mojo:9:4: note: candidate not viable: callee parameter #0 has 'MyTrait' type, but value has type 'MyOtherTrait'
fn do_something[T: MyTrait, key: StringLiteral]() -> T.DomainType:
   ^
bug.mojo:13:4: note: candidate not viable: callee expects 1 parameter, but 2 were specified
fn do_something[T: MyOtherTrait]() -> T.DomainType:
   ^
mojo: error: failed to parse the provided Mojo source module

Steps to reproduce

trait MyTrait:
    alias Type: Defaultable


trait MyOtherTrait(MyTrait):
    alias Type: Defaultable


fn do_something[T: MyTrait, key: StringLiteral]() -> T.Type:
    return T.Type()


fn do_something[T: MyOtherTrait]() -> T.Type:
    return do_something[T, "Hey"]()

System information

     Magic version: 0.5.1
System
------------
      Pixi version: 0.37.0
          Platform: linux-64
  Virtual packages: __unix=0=0
                  : __linux=6.13.1=0
                  : __glibc=2.41=0
                  : __archspec=1=skylake
         Cache dir: /home/thomas/.cache/rattler/cache
      Auth storage: /home/thomas/.rattler/credentials.json
  Config locations: No config files found
Package     Version               Build    Size       Kind   Source
max         25.2.0.dev2025030505  release  9.7 KiB    conda  max-25.2.0.dev2025030505-release.conda
max-core    25.2.0.dev2025030505  release  244.3 MiB  conda  max-core-25.2.0.dev2025030505-release.conda
max-python  25.2.0.dev2025030505  release  121.3 MiB  conda  max-python-25.2.0.dev2025030505-release.conda
@thomas-huegel thomas-huegel added bug Something isn't working mojo Issues that are related to mojo labels Mar 5, 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 max-repo mojo Issues that are related to mojo
Projects
None yet
Development

No branches or pull requests

2 participants