# Weird behaviour of macrocall in expression

**URL:** <https://discourse.julialang.org/t/weird-behaviour-of-macrocall-in-expression/8562>\
**Category:** General Usage\
**Created:** [January 24, 2018, 2:24pm UTC](https://discourse.julialang.org/t/weird-behaviour-of-macrocall-in-expression/8562 "2018-01-24T14:24:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohamed82008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed82008/32/18171_2.png) [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Post date:** [January 24, 2018, 2:24pm UTC](https://discourse.julialang.org/t/weird-behaviour-of-macrocall-in-expression/8562/1 "2018-01-24T14:24:40Z")

</div>

Is this behavior expected?

```julia
julia> dump(Expr(:macrocall, :@inbounds))
Expr
  head: Symbol macrocall
  args: Array{Any}((1,))
    1: Expr
      head: Symbol macrocall
      args: Array{Any}((1,))
        1: Symbol @inbounds
      typ: Any
  typ: Any

```

Why are there 2 `macrocall`s?

This is in contrast to:

```julia
julia> dump(:(@inbounds nothing))
Expr
  head: Symbol macrocall
  args: Array{Any}((2,))
    1: Symbol @inbounds
    2: Symbol nothing
  typ: Any

```

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [January 24, 2018, 2:40pm UTC](https://discourse.julialang.org/t/weird-behaviour-of-macrocall-in-expression/8562/2 "2018-01-24T14:40:11Z")

</div>

Maybe:

```julia
julia> dump(:@inbounds)
Expr
  head: Symbol macrocall
  args: Array{Any}((1,))
    1: Symbol @inbounds
  typ: Any

```

```julia
julia> dump(Expr(:macrocall, Symbol("@inbounds")))
Expr
  head: Symbol macrocall
  args: Array{Any}((1,))
    1: Symbol @inbounds
  typ: Any

```

---

<div class="post-metadata">

**Author:** ![mohamed82008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed82008/32/18171_2.png) [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Post date:** [January 24, 2018, 2:41pm UTC](https://discourse.julialang.org/t/weird-behaviour-of-macrocall-in-expression/8562/3 "2018-01-24T14:41:52Z")

</div>

Neat!

---

<div class="post-metadata">

**Author:** ![mohamed82008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed82008/32/18171_2.png) [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Post date:** [January 24, 2018, 8:38pm UTC](https://discourse.julialang.org/t/weird-behaviour-of-macrocall-in-expression/8562/4 "2018-01-24T20:38:50Z")

</div>

Btw, it gets even weirder in v0.7. Any idea how to build an `@inbounds` block in nightly? The following is my source of confusion.

```julia
julia> ex = Expr(:macrocall, Symbol("@inbounds"), :(a[1] = 1))
:(@inbounds)

julia> dump(ex)
Expr
  head: Symbol macrocall
  args: Array{Any}((2,))
    1: Symbol @inbounds
    2: Expr
      head: Symbol =
      args: Array{Any}((2,))
        1: Expr
          head: Symbol ref
          args: Array{Any}((2,))
            1: Symbol a
            2: Int64 1
          typ: Any
        2: Int64 1
      typ: Any
  typ: Any

julia> dump(:(@inbounds a[1] = 1))
Expr
  head: Symbol macrocall
  args: Array{Any}((3,))
    1: Symbol @inbounds
    2: LineNumberNode
      line: Int64 1
      file: Symbol REPL[107]
    3: Expr
      head: Symbol =
      args: Array{Any}((2,))
        1: Expr
          head: Symbol ref
          args: Array{Any}((2,))
            1: Symbol a
            2: Int64 1
          typ: Any
        2: Int64 1
      typ: Any
  typ: Any

```

It seems the only difference is the line info, which I shouldn’t really need. Any help is appreciated.

---

<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:** [January 24, 2018, 10:28pm UTC](https://discourse.julialang.org/t/weird-behaviour-of-macrocall-in-expression/8562/5 "2018-01-24T22:28:31Z")

</div>

> [@mohamed82008](#):
>
> It seems the only difference is the line info, which I shouldn’t really need. Any help is appreciated.

Yes you do. You must provide them.

---

<div class="post-metadata">

**Author:** ![mohamed82008](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mohamed82008/32/18171_2.png) [@mohamed82008](https://discourse.julialang.org/u/mohamed82008)\
**Post date:** [January 24, 2018, 10:42pm UTC](https://discourse.julialang.org/t/weird-behaviour-of-macrocall-in-expression/8562/6 "2018-01-24T22:42:12Z")

</div>

So which line is this referring to? I am making an expression in a generated function that uses an `@inbounds` block. So is it the line where I pushed the `@inbounds` expression to the block, or some other line? And does this mean if I press enter or rearrange functions, that I have to manually edit this all over the file!!!? Please tell me I am misunderstanding this.

---

<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:** [January 25, 2018, 12:44am UTC](https://discourse.julialang.org/t/weird-behaviour-of-macrocall-in-expression/8562/7 "2018-01-25T00:44:15Z")

</div>

> [@mohamed82008](#):
>
> So which line is this referring to

Whereever the user can find how the code is generated.

> [@mohamed82008](#):
>
> So is it the line where I pushed the @inbounds expression to the block,

So ideally, yes.

> [@mohamed82008](#):
>
> And does this mean if I press enter or rearrange functions, that I have to manually edit this all over the file!!!?

I mean, you can. But there’s `@ __LINE__ `.
