Skip to content

Commit

Permalink
fixes #22687; js backend - std/bitops/bitsliced throws compile error … (
Browse files Browse the repository at this point in the history
#22722)

…in typeMasked

fixes #22687
  • Loading branch information
ringabout committed Sep 20, 2023
1 parent d82bc0a commit ed30692
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/pure/bitops.nim
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ type BitsRange*[T] = range[0..sizeof(T)*8-1]

template typeMasked[T: SomeInteger](x: T): T =
when defined(js):
x and ((0xffffffff_ffffffff'u shr (64 - sizeof(T) * 8)))
T(x and ((0xffffffff_ffffffff'u shr (64 - sizeof(T) * 8))))
else:
x

Expand Down
4 changes: 4 additions & 0 deletions tests/stdlib/t21564.nim
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ proc main() =
# test `bitops.toMask` patch via bitops.masked
doAssert(0x12FFFF34.masked(8..23) == 0x00FFFF00)

block: # bug #22687
var a: uint8 = 0b1111_1111
doAssert a.bitsliced(4..7).int == 15

main()

static:
Expand Down

0 comments on commit ed30692

Please sign in to comment.