Skip to content

Commit

Permalink
Fix bitshift operators on Bool
Browse files Browse the repository at this point in the history
Previously triggered a stack overflow due to recursive definition.
  • Loading branch information
nalimilan committed Jun 17, 2016
1 parent 2faed27 commit 32b5c01
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions base/bool.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ typemax(::Type{Bool}) = true
(|)(x::Bool, y::Bool) = box(Bool,or_int(unbox(Bool,x),unbox(Bool,y)))
($)(x::Bool, y::Bool) = (x!=y)

>>(x::Bool, c::Unsigned) = Int(x) >> c
<<(x::Bool, c::Unsigned) = Int(x) << c
>>>(x::Bool, c::Unsigned) = Int(x) >>> c

signbit(x::Bool) = false
sign(x::Bool) = x
abs(x::Bool) = x
Expand Down
5 changes: 5 additions & 0 deletions test/int.jl
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,8 @@ end

# issue #16700
@test_throws MethodError 1.0 >> 8

# PR #16988
@test true << 2 === 1 << 2
@test true >> 2 === 1 >> 2
@test true >>> 2 === 1 >>> 2

0 comments on commit 32b5c01

Please sign in to comment.