# ERROR: syntax: unexpected semicolon in tuple around REPL

**URL:** <https://discourse.julialang.org/t/error-syntax-unexpected-semicolon-in-tuple-around-repl/129399>\
**Category:** General Usage\
**Tags:** semicolon, compound-expression\
**Created:** [May 28, 2025, 7:49am UTC](https://discourse.julialang.org/t/error-syntax-unexpected-semicolon-in-tuple-around-repl/129399 "2025-05-28T07:49:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![WalterMadelim](https://avatars.discourse-cdn.com/v4/letter/w/3e96dc/32.png) [@WalterMadelim](https://discourse.julialang.org/u/WalterMadelim)\
**Post date:** [May 28, 2025, 7:49am UTC](https://discourse.julialang.org/t/error-syntax-unexpected-semicolon-in-tuple-around-repl/129399/1 "2025-05-28T07:49:35Z")

</div>

Why can’t I write this compound expression? (The context is a Givens rotation)

```julia
julia> A = rand(-9:9, 2, 2)
2×2 Matrix{Int64}:
 -9 -9
 -1 1

julia> t = pi/3
1.0471975511965976

julia> c, s = cos(t), sin(t); [c s; -s c] * A
2×2 Matrix{Float64}:
 -5.36603 -3.63397
  7.29423 8.29423

julia> (c, s = cos(t), sin(t); [c s; -s c] * A)
ERROR: syntax: unexpected semicolon in tuple around REPL[4]:1
Stacktrace:
 [1] top-level scope
   @ REPL[4]:1

```

---

<div class="post-metadata">

**Author:** ![vchuravy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vchuravy/32/8_2.png) [@vchuravy](https://discourse.julialang.org/u/vchuravy)\
**Post date:** [May 28, 2025, 8:27am UTC](https://discourse.julialang.org/t/error-syntax-unexpected-semicolon-in-tuple-around-repl/129399/2 "2025-05-28T08:27:10Z")

</div>

Likely because `(; ...)` is reserved syntax for `NamedTuple`. Generally speaking, `()` is for creating tuple and it isn’t a compound expression, even just writing:

```julia
julia> (c, s = cos(t), sin(t))
ERROR: syntax: invalid named tuple element "sin(t)" around REPL[6]:1

```

You can write: `begin c, s = cos(t), sin(t); [c s; -s c] * A end`

---

<div class="post-metadata">

**Author:** ![WalterMadelim](https://avatars.discourse-cdn.com/v4/letter/w/3e96dc/32.png) [@WalterMadelim](https://discourse.julialang.org/u/WalterMadelim)\
**Post date:** [May 28, 2025, 9:54am UTC](https://discourse.julialang.org/t/error-syntax-unexpected-semicolon-in-tuple-around-repl/129399/3 "2025-05-28T09:54:05Z")

</div>

Interestingly, this works

```julia
julia> A = rand(-9:9, 2, 2); t = pi/3;

julia> ((c, s) = (cos(t), sin(t)); [c s; -s c] * A)
2×2 Matrix{Float64}:
  4.29423 3.5
 10.5622 -6.06218

```

---

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [May 28, 2025, 12:32pm UTC](https://discourse.julialang.org/t/error-syntax-unexpected-semicolon-in-tuple-around-repl/129399/4 "2025-05-28T12:32:32Z")

</div>

It’s just one of those arbitrary parser decisions when looser convenient syntax overlaps. `((c, s) = (cos(t), sin(t)); [c s; -s c] * A)` happened to work because the extra parentheses isolated the comma from the outer parentheses, so it was no longer recognized as a plain or named tuple:

```julia
julia> 1; 2, 3
(2, 3)

julia> (1; 2, 3)
ERROR: syntax: unexpected semicolon in tuple around REPL[33]:1
Stacktrace:
 [1] top-level scope
   @ REPL[33]:1

julia> (1; (2, 3))
(2, 3)

```

Use the less ambiguous multi-line syntax like `begin` blocks to evade these overlaps.

---

<div class="post-metadata">

**Author:** ![savq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/savq/32/22063_2.png) [@savq](https://discourse.julialang.org/u/savq)\
**Post date:** [May 28, 2025, 2:22pm UTC](https://discourse.julialang.org/t/error-syntax-unexpected-semicolon-in-tuple-around-repl/129399/5 "2025-05-28T14:22:48Z")

</div>

Note that the expression does parse, because it’s needed for function arguments:

```julia-repl
julia> :(c, s = cos(t), sin(t); [c s; -s c] * A)
:((c, s = cos(t), sin(t); [c s; -s c] * A))

```

However, it’ts parsed as

```julia
(c, (s = cos(t)), sin(t); [c s; -s c] * A)

```

It’s only during lowering that Julia forbids this form.
