From 32b5c017ebc6ea6ad94a7a7e67382f8dbf1ff23e Mon Sep 17 00:00:00 2001 From: Milan Bouchet-Valat Date: Fri, 17 Jun 2016 21:04:27 +0200 Subject: [PATCH] Fix bitshift operators on Bool Previously triggered a stack overflow due to recursive definition. --- base/bool.jl | 4 ++++ test/int.jl | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/base/bool.jl b/base/bool.jl index cef413455db46..c867ede02515d 100644 --- a/base/bool.jl +++ b/base/bool.jl @@ -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 diff --git a/test/int.jl b/test/int.jl index 40b79c726d2ac..cc724bac92173 100644 --- a/test/int.jl +++ b/test/int.jl @@ -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