fixes #22687; js backend - std/bitops/bitsliced throws compile error … (#22722)

…in typeMasked

fixes #22687
This commit is contained in:
ringabout
2023-09-21 06:35:48 +08:00
committed by GitHub
parent d82bc0a29f
commit ed30692d29
2 changed files with 5 additions and 1 deletions

View File

@@ -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

View File

@@ -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: