modularml / mojo

The Mojo Programming Language
https://docs.modular.com/mojo/manual/
Other
22.92k stars 2.58k forks source link

[BUG] ..cannot be converted from 'List[Int]' to 'List[Int]' #2956

Open sa- opened 3 months ago

sa- commented 3 months ago

Bug description

The error is invalid initialization: argument #1 cannot be converted from 'List[Int]' to 'List[Int]', although I would hope the compiler would be able to handle this

Steps to reproduce

Clone the arrow.mojo repo at this commit: https://github.com/mojo-data/arrow.mojo/commit/271d9207e51d78c978303c1885c2a8a9a57e36e7

git clone https://github.com/mojo-data/arrow.mojo.git
cd arrow.mojo
git checkout 271d920

And then run

mojo test -I .

System information

- What OS did you do install Mojo on ?
MacOS
- Provide version information for Mojo by pasting the output of `mojo -v`
mojo 2024.5.2205 (d3cacc7e)
- Provide Modular CLI version by pasting the output of `modular -v`
modular 0.8.0 (39a426b5)
sa- commented 3 months ago

And on a different note the LSP doesn't seem to recognize the arrow/ dir, this feels like it might have been reported but I wasn't able to find an issue for it. Would be happy to file a separate issue "LSP should include root directory in its mojo path" if needed

ematejska commented 3 months ago

Contained Reproducer

struct ArrowFixedWidthBuffer[T: AnyTrivialRegType]:
    fn __init__(inout self, values: List[T]):
        var byte_width = sizeof[T]()

def main():
    var int_arrow_buf = ArrowFixedWidthBuffer(List[Int]())
martinvuyk commented 3 months ago

FYI @sa- temporary workaround:

struct ArrowFixedWidthBuffer[T: AnyTrivialRegType]:
    alias _type = T

    fn __init__(inout self, values: List[Self._type]):
        var byte_width = sizeof[T]()

def main():
    alias Arr = ArrowFixedWidthBuffer[Int]
    var int_arrow_buf = Arr(List[Arr._type]())