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] Can't form alias to Int's dunder methods #3213

Open
soraros opened this issue Jul 10, 2024 · 6 comments
Open

[BUG] Can't form alias to Int's dunder methods #3213

soraros opened this issue Jul 10, 2024 · 6 comments
Labels
bug Something isn't working mojo-repo Tag all issues with this label QOI

Comments

@soraros
Copy link
Contributor

soraros commented Jul 10, 2024

Bug description

As title. It's odd since most other types work.

Steps to reproduce

fn main():
	alias le = Int.__le__  # error: cannot form a reference to overloaded declaration of '__le__'

System information

Mojo 2024.7.1022 (1e94b6a0)
@soraros soraros added bug Something isn't working mojo-repo Tag all issues with this label labels Jul 10, 2024
Copy link
Collaborator

Mogball commented Jul 12, 2024

cannot form a reference to overloaded declaration of '__le__'

This is intended behaviour. The real question is whether this method should be overloaded.

Copy link
Collaborator

Mogball commented Jul 12, 2024

Will defer to @joe

@soraros
Copy link
Contributor Author

soraros commented Jul 12, 2024

This is intended behaviour. The real question is whether this method should be overloaded.

That's the thing: it's not overloaded, unless overloading means something very different in Mojo.

Copy link
Collaborator

Mogball commented Jul 12, 2024

Ah, then this is indeed a bug

@soraros
Copy link
Contributor Author

soraros commented Jul 12, 2024

It also happens to Bool, but for instance not to SIMD.

@soraros
Copy link
Contributor Author

soraros commented Jul 13, 2024

The problem seems to be that @register_passable doesn't work well with trait explicit bound (EqualityComparable in this case). If either is removed, the problem goes away.

fn main():
    Int.__eq__

@register_passable
struct Int(EqualityComparable):
    fn __eq__(self, rhs: Self) -> Bool:
        return False

    fn __ne__(self, rhs: Self) -> Bool:
        return False

@ematejska ematejska added the QOI label Jul 18, 2024 — with Linear
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 QOI
Projects
None yet
Development

No branches or pull requests

3 participants