Passing generics to DynamicVector
I'm trying to understand the traits system and am working with a toy
list
struct from this thread
The original declaration (which works) starts with:
In the above I can declare a list of strings with list[String]
I have tried to add the ability to print items in the list
, but CollectionElement
s aren't accepted by str
(errors with "no matching function in call to 'str'"), so I tried making a trait that inherits from both requirements:
This removes the compile error in my print method, but then I can no longer declare list[String]
. In this declaration
the compiler errors with "'list' parameter #0 has 'ListElement' type, but value has type 'String'". But it seems like String
should satisfy my new trait since it satisfied CollectionElement
and should certainly satisfy Stringable
. Am I doing something wrong, or is this a current bug/limitation of Mojo?GitHub
[BUG]: Mojo is getting confused in 0.6.0 with overloading and slice...
Bug description The compiler is choosing the wrong overload, making it break the program at runtime. Steps to reproduce Consider the following code: @value struct list[T: CollectionElement]: var _i...
0 Replies