Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content
New issue

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

[BUG] 0/0 != 1 returns False #3321

Open
helehex opened this issue Jul 27, 2024 · 3 comments
Open

[BUG] 0/0 != 1 returns False #3321

helehex opened this issue Jul 27, 2024 · 3 comments
Labels
bug Something isn't working mojo-repo Tag all issues with this label

Comments

@helehex
Copy link
Contributor

helehex commented Jul 27, 2024

Bug description

Maybe I'm mistaken, but shouldn't nan != x always return True?
When using the math.nan[]() function to provide the nan, it returns True.
This means that nan behaves differently right now, depending on it's payload bits.

Steps to reproduce

fn main():
    print(0/0 != 1)

System information

Host Information
  ================

  Target Triple: x86_64-unknown-linux
  CPU: skylake
  CPU Features: adx, aes, avx, avx2, bmi, bmi2, clflushopt, cmov, crc32, cx16, cx8, f16c, fma, fsgsbase, fxsr, invpcid, lzcnt, mmx, movbe, pclmul, popcnt, prfchw, rdrnd, rdseed, sahf, sgx, sse, sse2, sse3, sse4.1, sse4.2, ssse3, x87, xsave, xsavec, xsaveopt, xsaves

mojo 2024.7.2705 (4b7a0ee2)

modular 0.8.0 (39a426b5)
@helehex helehex added bug Something isn't working mojo-repo Tag all issues with this label labels Jul 27, 2024
@helehex
Copy link
Contributor Author

helehex commented Jul 27, 2024

BTW: I found this because I was noticing false positives in my unit tests. So be careful I guess.

@luanon404
Copy link

even use != or == the result still False

@soraros
Copy link
Contributor

soraros commented Jul 29, 2024

0 / 0 doesn't run at compile time at all:

fn main():
  alias a = 0 / 0
  print(a)

Error message:

/__w/modular/modular/open-source/mojo/stdlib/stdlib/builtin/_startup.mojo:113:4: error: call expansion failed
/__w/modular/modular/open-source/mojo/stdlib/stdlib/builtin/_startup.mojo:44:4: note: function instantiation failed
<unknown>:0: note: failed to compile-time evaluate function call
/__w/modular/modular/open-source/mojo/stdlib/stdlib/builtin/int.mojo:552:8: note: failed to interpret function @stdlib::builtin::int::Int::__truediv__(::Int,::Int)
/__w/modular/modular/open-source/mojo/stdlib/stdlib/builtin/int.mojo:561:30: note: call expansion failed
/__w/modular/modular/open-source/mojo/stdlib/stdlib/builtin/simd.mojo:563:35: note: failed to fold operation pop.div(#pop<simd "0"> : !pop.scalar<f64>, #pop<simd "0"> : !pop.scalar<f64>)
/home/vscode/.modular/pkg/packages.modular.com_nightly_mojo/bin/mojo: error: failed to run the pass manager

Maybe we should just implement a __truediv__ -> FloatLiteral on IntLiteral?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mojo-repo Tag all issues with this label
Projects
None yet
Development

No branches or pull requests

3 participants