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] __getitem__(self, Slice) with __refitem__ gives callee expects 2 parameters, but 0 were specified #2540

Closed
mikowals opened this issue May 6, 2024 · 0 comments
Labels
blocker bug Something isn't working mojo-repo Tag all issues with this label

Comments

@mikowals
Copy link
Contributor

mikowals commented May 6, 2024

Bug description

A problem in the __getitem__ or __refitem__ sugar syntax using brackets. Encountered implementing #2432.

Steps to reproduce

from memory import UnsafePointer
 
@value
struct Foo:
    var data: UnsafePointer[Int]
 
    fn __init__(inout self):
        pass
 
    @always_inline
    fn __refitem__[
        mutability: __mlir_type.`i1`, self_life: AnyLifetime[mutability].type
    ](
        self: Reference[Self, mutability, self_life]._mlir_type,
        i: Int,
    ) -> Reference[Int, mutability, self_life]:
        var ptr = Reference(self)[].data
        return ptr[]
 
    @always_inline
    fn __getitem__(self, span: Slice) -> Self:
        return Self()
 
    @always_inline
    fn __str__(self) -> String:
        return "foo"
 
 
fn main():
    var foo = Foo()
    print(foo[0:1:1]) # error: invalid call to '__refitem__': callee expects 2 parameters ...
    # print(foo.__getitem__(slice(0, 1, 1))) # this one works

System information

- MacOS Sonoma 14.4.1 (23E224)
- mojo 2024.5.323 (1d9276ea)
- modular 0.7.2 (d0adc668)
@mikowals mikowals added bug Something isn't working mojo-repo Tag all issues with this label labels May 6, 2024
@ematejska ematejska added mojo-repo Tag all issues with this label and removed mojo-repo Tag all issues with this label labels May 6, 2024
@ematejska ematejska added the mojo-stdlib Tag for issues related to standard library label May 7, 2024 — with Linear
@JoeLoser JoeLoser removed the mojo-stdlib Tag for issues related to standard library label May 10, 2024
@JoeLoser JoeLoser added the blocker label May 10, 2024 — with Linear
@linear linear bot closed this as not planned Won't fix, can't repro, duplicate, stale May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker bug Something isn't working mojo-repo Tag all issues with this label
Projects
None yet
Development

No branches or pull requests

3 participants