# Bug with \`@.\`

**URL:** <https://discourse.julialang.org/t/bug-with/48940>\
**Category:** General Usage\
**Created:** [October 24, 2020, 3:18pm UTC](https://discourse.julialang.org/t/bug-with/48940 "2020-10-24T15:18:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [October 24, 2020, 3:18pm UTC](https://discourse.julialang.org/t/bug-with/48940/1 "2020-10-24T15:18:56Z")

</div>

I think I’ve found a bug with the `@.` macro

```julia
julia> function foo(;x = 0, y = 8)
       return x
       end
foo (generic function with 1 method)

julia> a = [1, 2, 3]; b = [4, 5, 6];

julia> foo(; x = @. a * b, y = b)
ERROR: DimensionMismatch("array could not be broadcast to match destination")

```

I think `@.` is being too “greedy”, for lack of a better word. It’s not respecting the fact that it’s scope ends at the `,`. For instance

```julia
julia> foo(; x = @. a * b,)
ERROR: syntax: unexpected ")"

```

But

```julia
julia> foo(;x = @. a & b)
3-element Array{Int64,1}:
 0
 0
 2

```

Sorry for focusing on keyword arguments, here is another example with positional arguments.

```julia
julia> bar(x, y) = x 
bar (generic function with 1 method)

julia> bar(@. a * b, b)
ERROR: MethodError: no method matching bar(::Tuple{Array{Int64,1},Array{Int64,1}})

```

---

<div class="post-metadata">

**Author:** ![Per](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/per/32/10387_2.png) [@Per](https://discourse.julialang.org/u/Per)\
**Post date:** [October 24, 2020, 4:15pm UTC](https://discourse.julialang.org/t/bug-with/48940/2 "2020-10-24T16:15:31Z")

</div>

Without parentheses, the parser will give all arguments to the macro. This is not specific to the `@.` macro. Try, for example, `bar(@show a + b, b)`; It will give the same error.

To delimit what goes to the macro, use either a newline:

```julia
 bar(@. a * b
     , b)

```

or parentheses

```julia
bar(@.(a * b), b)

```

---

<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:** [October 24, 2020, 4:18pm UTC](https://discourse.julialang.org/t/bug-with/48940/3 "2020-10-24T16:18:08Z")

</div>

> [@pdeffebach](#):
>
> `foo(; x = @. a * b, y = b)`

You need `@.(a * b)` or `(@. a * b)`.

This is not a bug, and is not specific to `@.` — any macro takes as much of the next expression as possible. That is, `@. a * b, y = b` is equivalent to `@. (a * b, y = b)` — it is parsing the next two arguments as a tuple.

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [October 24, 2020, 4:39pm UTC](https://discourse.julialang.org/t/bug-with/48940/4 "2020-10-24T16:39:10Z")

</div>

Indeed

```julia
julia> macro t(x)
       @show x
       x
       end
@t (macro with 1 method)

julia> bar(@t a, b)
x = :((a, b))

```

Thanks. I guess this allows stuff like

```julia
@unpack a, b = x

```

to work.

Note that you can also do

```julia
bar(begin @. a * b end, b)

```

which might be more intuitive for a complicated expression.
