# Weird error when trying to use \`≔\` (\\coloneq) as infix operator

**URL:** <https://discourse.julialang.org/t/weird-error-when-trying-to-use-coloneq-as-infix-operator/21578>\
**Category:** General Usage\
**Tags:** infix\
**Created:** [March 7, 2019, 3:24pm UTC](https://discourse.julialang.org/t/weird-error-when-trying-to-use-coloneq-as-infix-operator/21578 "2019-03-07T15:24:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![simeonschaub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simeonschaub/32/216566_2.png) [@simeonschaub](https://discourse.julialang.org/u/simeonschaub)\
**Post date:** [March 7, 2019, 3:24pm UTC](https://discourse.julialang.org/t/weird-error-when-trying-to-use-coloneq-as-infix-operator/21578/1 "2019-03-07T15:24:08Z")

</div>

When overloading `≔` like this:

```julia-auto
julia> ≔(a, b) = a==b
≔ (generic function with 1 method)

```

the following works just fine:

```julia-auto
julia> ≔(3,2)
false

```

But I get a weird error when trying to use it as an infix-operator:

```julia-auto
julia> 2≔3
ERROR: syntax: invalid syntax (≔ 2 3)

```

Is this even supposed to work? The error message looks more like a bug in Julia’s Lisp parser or maybe I’m missing something?

---

<div class="post-metadata">

**Author:** ![StevenSiew](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevensiew/32/218393_2.png) [@StevenSiew](https://discourse.julialang.org/u/StevenSiew)\
**Post date:** [August 26, 2025, 10:13pm UTC](https://discourse.julialang.org/t/weird-error-when-trying-to-use-coloneq-as-infix-operator/21578/2 "2025-08-26T22:13:01Z")

</div>

The list of symbols recognized as infix operators (and associated precedence) can be found in the Julia parser source code. For the most part, this list is a subset of unicode category Sm(Symbol, math).

At the moment, it includes for example:

parsed with the same precedence as + (addition):

```julia-auto
+ - ⊕ ⊖ ⊞ ⊟ ∪ ∨ ⊔ ± ∓ ∔ ∸ ≏ ⊎ ⊻ ⊽ ⋎ ⋓ ⧺ ⧻ ⨈ ⨢ ⨣ ⨤ ⨥ ⨦
⨧ ⨨ ⨩ ⨪ ⨫ ⨬ ⨭ ⨮ ⨹ ⨺ ⩁ ⩂ ⩅ ⩊ ⩌ ⩏ ⩐ ⩒ ⩔ ⩖ ⩗ ⩛ ⩝ ⩡ ⩢ ⩣

```

parsed with the same precedence as \* (multiplication):

```julia-auto
* / ÷ % & ⋅ ∘ × ∩ ∧ ⊗ ⊘ ⊙ ⊚ ⊛ ⊠ ⊡ ⊓ ∗ ∙ ∤ ⅋ ≀ ⊼ ⋄ ⋆ ⋇
⋉ ⋊ ⋋ ⋌ ⋏ ⋒ ⟑ ⦸ ⦼ ⦾ ⦿ ⧶ ⧷ ⨇ ⨰ ⨱ ⨲ ⨳ ⨴ ⨵ ⨶ ⨷ ⨸ ⨻
⨼ ⨽ ⩀ ⩃ ⩄ ⩋ ⩍ ⩎ ⩑ ⩓ ⩕ ⩘ ⩚ ⩜ ⩞ ⩟ ⩠ ⫛ ⊍ ▷ ⨝ ⟕ ⟖ ⟗

```

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [August 27, 2025, 11:16am UTC](https://discourse.julialang.org/t/weird-error-when-trying-to-use-coloneq-as-infix-operator/21578/3 "2025-08-27T11:16:53Z")

</div>

> [@simeonschaub](#):
>
> Is this even supposed to work?

I believe you can only use it as an infix operator in a macro. It _is_ parsed as an infix operator:

```julia-auto
julia> dump(:(2 ≔ 3))
Expr
  head: Symbol ≔
  args: Array{Any}((2,))
    1: Int64 2
    2: Int64 3

```

with assignment precedence, but you can’t overload assignment operators. The 1.13 parser gives a more descriptive error:

```julia-auto
julia> 3 ≔ 2
ERROR: syntax: unsupported assignment operator "≔"
Stacktrace:
 [1] top-level scope
   @ REPL[4]:1

```

However, since it is parsed, you can write a macro that rewrites it into something else. You can do the same thing with `:=`.

```julia-auto
julia> dump(:(2 := 3))
Expr
  head: Symbol :=
  args: Array{Any}((2,))
    1: Int64 2
    2: Int64 3

julia> Base.operator_precedence(:(=))
1

julia> Base.operator_precedence(:(:=))
1

julia> Base.operator_precedence(:(≔))
1

```

See also [Is it possible to overload `:=`?](https://discourse.julialang.org/t/is-it-possible-to-overload/95547)

PS. Whoops, I didn’t realize that this was an ancient thread.
