You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using a parameter DType in a function, the compiler sometimes fails to convert from Float64 to Scalar[DType]. See the code snippets below.
Steps to reproduce
Include relevant code snippet or link to code that did not work as expected.
snippet1:
fnf[type: DType](i: Int) -> None:
constrained[type.is_floating_point(), "type failed to be a floating point type"]();varval: Scalar[type] =1.0/ i; #fails to compile here#...
Whereas the following two snippets both work.
fnf[type: DType](i: Int) -> None:
constrained[type.is_floating_point(), "type failed to be a floating point type"]();varval: Scalar[type] =1.0;
val /= i;#...
fnf[type: DType](i: Int) -> None:
constrained[type.is_floating_point(), "type failed to be a floating point type"]();varval: Scalar[type] = rebind[Scalar[type]](1.0/ i);#...
The failure in snippet 1 is unexpected since the expression evaluates to Float64 which should be convertible to Scalar[DType], without the need for rebind. The failure is observed in both the stand alone compiler and the playground.
System information
- What OS did you do install Mojo on ? ubuntu 22.04 LTS
- Provide version information for Mojo by pasting the output of `mojo -v` mojo 24.5.0 (e8aacb95)
- Provide Magic CLI version by pasting the output of `magic -V` or `magic --version` magic 0.4.0 - (based on pixi 0.33.0)
The text was updated successfully, but these errors were encountered:
Bug description
When using a parameter DType in a function, the compiler sometimes fails to convert from Float64 to Scalar[DType]. See the code snippets below.
Steps to reproduce
snippet1:
Whereas the following two snippets both work.
The failure in snippet 1 is unexpected since the expression evaluates to Float64 which should be convertible to Scalar[DType], without the need for rebind. The failure is observed in both the stand alone compiler and the playground.
System information
The text was updated successfully, but these errors were encountered: