Skip to content

Commit 32b5c01

Browse files
committed
Fix bitshift operators on Bool
Previously triggered a stack overflow due to recursive definition.
1 parent 2faed27 commit 32b5c01

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

base/bool.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ typemax(::Type{Bool}) = true
2020
(|)(x::Bool, y::Bool) = box(Bool,or_int(unbox(Bool,x),unbox(Bool,y)))
2121
($)(x::Bool, y::Bool) = (x!=y)
2222

23+
>>(x::Bool, c::Unsigned) = Int(x) >> c
24+
<<(x::Bool, c::Unsigned) = Int(x) << c
25+
>>>(x::Bool, c::Unsigned) = Int(x) >>> c
26+
2327
signbit(x::Bool) = false
2428
sign(x::Bool) = x
2529
abs(x::Bool) = x

test/int.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,8 @@ end
190190

191191
# issue #16700
192192
@test_throws MethodError 1.0 >> 8
193+
194+
# PR #16988
195+
@test true << 2 === 1 << 2
196+
@test true >> 2 === 1 >> 2
197+
@test true >>> 2 === 1 >>> 2

0 commit comments

Comments
 (0)