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] Cant instantiate variable of UInt256 with more than 128 bit value #4049

Open
xtxtxtxtxtxtx opened this issue Mar 4, 2025 · 2 comments
Labels
bug Something isn't working max-repo mojo Issues that are related to mojo

Comments

@xtxtxtxtxtxtx
Copy link

Bug description

open-source/mojo/stdlib/stdlib/builtin/_startup.mojo:114:4: error: call expansion failed
open-source/mojo/stdlib/stdlib/builtin/_startup.mojo:45:4: note: function instantiation failed
:0: note: call expansion failed
open-source/mojo/stdlib/stdlib/builtin/simd.mojo:425:8: note: function instantiation failed
:0: note: integer value 170141183460469231731687303715884105728 requires 129 bits to store, but the destination bit width is only 128 bits wide

Steps to reproduce

fn main():
    alias Uint256 = Scalar[DType.uint256]
    var a: Uint256 = 170141183460469231731687303715884105727
    a += 1
    var b: Uint256 = a #This works 
    var c: Uint256 = 170141183460469231731687303715884105728 # This does not
    print(b, c)

System information

max 25.2.0.dev2025030405

@xtxtxtxtxtxtx xtxtxtxtxtxtx added bug Something isn't working mojo Issues that are related to mojo labels Mar 4, 2025
@xtxtxtxtxtxtx
Copy link
Author

fn main():
    var a: UInt256 = 2**256 - 1  # 115792089237316195423570985008687907853269984665640564039457584007913129639935
    var b: UInt256 = 2**255 - 1  # 115792089237316195423570985008687907853269984665640564039457584007913129639935
    # should be 57896044618658097711785492504343953926634992332820282019728792003956564819967
    var c: UInt256 = 2**64 - 1  # 115792089237316195423570985008687907853269984665640564039457584007913129639935
    # should be 18446744073709551615
    print(a == b == c)  # True should be False

System Information
max 25.2.0.dev2025030619

@soraros
Copy link
Contributor

soraros commented Mar 7, 2025

I think this is the problem

var t0 = __mlir_op.`pop.cast_from_builtin`[
_type = __mlir_type.`!pop.scalar<si128>`
](tn1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working max-repo mojo Issues that are related to mojo
Projects
None yet
Development

No branches or pull requests

3 participants