We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
__getitem__(self, Slice)
__refitem__
A problem in the __getitem__ or __refitem__ sugar syntax using brackets. Encountered implementing #2432.
__getitem__
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
- MacOS Sonoma 14.4.1 (23E224) - mojo 2024.5.323 (1d9276ea) - modular 0.7.2 (d0adc668)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Bug description
A problem in the
__getitem__
or__refitem__
sugar syntax using brackets. Encountered implementing #2432.Steps to reproduce
System information
The text was updated successfully, but these errors were encountered: