Type system does not recognize that a literal int is equal to an Int alias
I have a simple struct called Cube:
I've simplified the code: what remains is the following issue. (Obviously, in this contrived example, N can just be replaced by 1), but for real-world code, I cannot.
Error:
cannot implicitly convert 'Cube[T, N]' value to 'Cube[T, 1]' in return value
mojo 0.4.0 (9e33b013)
Question: Does anyone know how to cast
my x
(of type Cube[T, N]
to Cube[T, 1]
? Or is there another way to get the type system to accept this?3 Replies
seems like a bug
works when you put the alias outside of the fn
this may be related
https://github.com/modularml/mojo/issues/1028
GitHub
[BUG]: Types in aliases do not work as expected · Issue #1028 · mod...
Bug description Using aliases for types produces errors unexpectedly, when the user would expect them to be essentially substituted. Steps to reproduce The following fails: fn nothing() -> None:...
Thanx for digging; that issue is precisely my problem.