# Bool literals redefinition

**URL:** <https://discourse.julialang.org/t/bool-literals-redefinition/3722>\
**Category:** Internals & Design\
**Tags:** proposal\
**Created:** [May 15, 2017, 3:07pm UTC](https://discourse.julialang.org/t/bool-literals-redefinition/3722 "2017-05-15T15:07:33Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![cdsousa](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cdsousa/32/215553_2.png) [@cdsousa](https://discourse.julialang.org/u/cdsousa)\
**Post date:** [May 15, 2017, 3:07pm UTC](https://discourse.julialang.org/t/bool-literals-redefinition/3722/1 "2017-05-15T15:07:33Z")

</div>

Hi, shouldn’t this be disallowed, just to play on the safe side?

```julia
julia> function f()
           true = false
           return true
       end

julia> f()
false

```

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [May 15, 2017, 3:13pm UTC](https://discourse.julialang.org/t/bool-literals-redefinition/3722/2 "2017-05-15T15:13:45Z")

</div>

Which version are you using? It should be a syntax error.

---

<div class="post-metadata">

**Author:** ![cdsousa](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cdsousa/32/215553_2.png) [@cdsousa](https://discourse.julialang.org/u/cdsousa)\
**Post date:** [May 15, 2017, 3:14pm UTC](https://discourse.julialang.org/t/bool-literals-redefinition/3722/3 "2017-05-15T15:14:49Z")

</div>

Sorry, it’s

```julia
Julia Version 0.5.0
Commit 3c9d753 (2016-09-19 18:14 UTC)
Platform Info:
  System: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Prescott)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.7.1 (ORCJIT, broadwell)

```

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [May 15, 2017, 3:17pm UTC](https://discourse.julialang.org/t/bool-literals-redefinition/3722/4 "2017-05-15T15:17:02Z")

</div>

I don’t think we’ll get a lot of trouble by allowing this since it’ll be scoped but I believe it’s syntax error on 0.6.

OT: it seems that you might want a newer build or at least with a newer openblas…

---

<div class="post-metadata">

**Author:** ![cdsousa](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cdsousa/32/215553_2.png) [@cdsousa](https://discourse.julialang.org/u/cdsousa)\
**Post date:** [May 15, 2017, 3:18pm UTC](https://discourse.julialang.org/t/bool-literals-redefinition/3722/5 "2017-05-15T15:18:32Z")

</div>

Thanks, downloading v0.5.2 …

---

<div class="post-metadata">

**Author:** ![cdsousa](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cdsousa/32/215553_2.png) [@cdsousa](https://discourse.julialang.org/u/cdsousa)\
**Post date:** [May 15, 2017, 3:24pm UTC](https://discourse.julialang.org/t/bool-literals-redefinition/3722/6 "2017-05-15T15:24:07Z")

</div>

Indeed, in 0.6 it gives  
`ERROR: syntax: invalid assignment location "true"`  
just like if one tries to assign something to an integer literal.

---

<div class="post-metadata">

**Author:** ![yurivish](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yurivish/32/307_2.png) [@yurivish](https://discourse.julialang.org/u/yurivish)\
**Post date:** [May 15, 2017, 4:45pm UTC](https://discourse.julialang.org/t/bool-literals-redefinition/3722/7 "2017-05-15T16:45:11Z")

</div>

Relatedly, assigning to `where` still works on 0.6.0-rc1. 😃

[https://github.com/JuliaLang/julia/issues/20337](https://github.com/JuliaLang/julia/issues/20337)

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [May 15, 2017, 6:20pm UTC](https://discourse.julialang.org/t/bool-literals-redefinition/3722/8 "2017-05-15T18:20:46Z")

</div>

`where` is quite different. It is not a reference/literal that represent an object/variable so assigning a value to it have no affect on any normal usage of `where`. OTOH, changing the value of `true` and `false` could, though not really practically since I don’t think this is something one would accidentally do…

Allowing `where` to be used still as a variable could minimizing breakage, since it was allowed to be used as a variable in earlier versions. Obviously you can use it to create confusing looking code but that’s not at all a property of `where`.

---

<div class="post-metadata">

**Author:** ![yurivish](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yurivish/32/307_2.png) [@yurivish](https://discourse.julialang.org/u/yurivish)\
**Post date:** [May 15, 2017, 6:23pm UTC](https://discourse.julialang.org/t/bool-literals-redefinition/3722/9 "2017-05-15T18:23:05Z")

</div>

Good point, I hadn’t considered backwards compatibility issues. And thinking about it more, it would be good to keep it free for use as a variable name so long as it isn’t abused.

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [May 15, 2017, 6:31pm UTC](https://discourse.julialang.org/t/bool-literals-redefinition/3722/10 "2017-05-15T18:31:23Z")

</div>

Right. Another way to put it is that we are not going to make `wherewhere` a syntax error and `wherewhere where wherewhere where wherewhere` is arguably worse than the cases in the issue…
