# Overloading ≫ yields ERROR: TypeError: non-boolean used in boolean context

**URL:** https://discourse.julialang.org/t/overloading-yields-error-typeerror-non-boolean-used-in-boolean-context/64132
**Category:** General Usage
**Tags:** question
**Created:** [July 6, 2021, 8:06am UTC](https://discourse.julialang.org/t/overloading-yields-error-typeerror-non-boolean-used-in-boolean-context/64132 "2021-07-06T08:06:27Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![schlichtanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/schlichtanders/32/32145_2.png) [@schlichtanders](https://discourse.julialang.org/u/schlichtanders)
#### Post date: [July 6, 2021, 8:06am UTC](https://discourse.julialang.org/t/overloading-yields-error-typeerror-non-boolean-used-in-boolean-context/64132/1 "2021-07-06T08:06:27Z")

</div>

Can anyone help why this weird error happens? (working on julia 1.6.1)

```julia
julia> a ≫ b = a + b
≫ (generic function with 1 method)

julia> (1 ≫ 2) ≫ 3
6

julia> 1 ≫ (2 ≫ 3)
6

julia> 1 ≫ 2 ≫ 3
ERROR: TypeError: non-boolean (Int64) used in boolean context
Stacktrace:
 [1] top-level scope
   @ REPL[2]:1

```

Of course for me it would be awesome to just not having the error, but I guess that is not possible. Hence does someone know a similar unicode operator which does not yield this error?

---

<div class="post-metadata">

### Author: ![Luapulu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/luapulu/32/17669_2.png) [@Luapulu](https://discourse.julialang.org/u/Luapulu)
#### Post date: [July 6, 2021, 8:16am UTC](https://discourse.julialang.org/t/overloading-yields-error-typeerror-non-boolean-used-in-boolean-context/64132/2 "2021-07-06T08:16:42Z")

</div>

Try

```julia
julia> Meta.@lower 1 ≫ 2 ≫ 3
:($(Expr(:thunk, CodeInfo(
    @ none within `top-level scope'
1 ─ %1 = 1 ≫ 2
└── goto #3 if not %1
2 ─ %3 = 2 ≫ 3
└── return %3
3 ─ return false
))))

```

I have no idea why it lowers to a conditional go to based on the result of `1 ≫ 2`. With brackets it works though.

```julia
julia> (1 ≫ 2) ≫ 3
6

julia> 1 ≫ (2 ≫ 3)
6

```

---

<div class="post-metadata">

### Author: ![schlichtanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/schlichtanders/32/32145_2.png) [@schlichtanders](https://discourse.julialang.org/u/schlichtanders)
#### Post date: [July 6, 2021, 8:19am UTC](https://discourse.julialang.org/t/overloading-yields-error-typeerror-non-boolean-used-in-boolean-context/64132/3 "2021-07-06T08:19:04Z")

</div>

thank you for the lowering hint, I goes it is because this operator has the name “greater greater” and someone put “greater” comparison semantics onto it

a bit unfortunate as I wanted to use it for monad composition, where this unicode is quite commonly used as an operator

---

<div class="post-metadata">

### Author: ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)
#### Post date: [July 6, 2021, 9:56am UTC](https://discourse.julialang.org/t/overloading-yields-error-typeerror-non-boolean-used-in-boolean-context/64132/4 "2021-07-06T09:56:07Z")

</div>

This is to support [chaining](https://docs.julialang.org/en/v1/manual/mathematical-operations/#Chaining-comparisons) of comparisons. See also [this issue](https://github.com/JuliaLang/julia/issues/39104). As noted there you’d probably have to use a macro to work around the lowering.
