Inconsistency of line continuation after comma in script vs REPL

I have the following code:

x = 1,
2

And now:

  • If I save it to a file and execute then x is a tuple (1,2).
  • If I copy-paste it to REPL then x is a tuple (1,).

However, if I wrap the expression in the code block, e.g. begin-end, like this:

begin
x = 1,
2
end

then x is (1,2) both when run as a script and when copy-pasted to REPL.

I wanted to ask if this is an intended inconsistency?

EDIT:

Additionally we have:

julia> begin
       x = 1,
       end
ERROR: syntax: unexpected "end"

and

julia> (x=1,) # it is a one-element named tuple
(x = 1,)

Given all this and https://docs.julialang.org/en/latest/manual/functions/#Tuples-1 I think that:

julia> x = 1,

should throw an error as it is ambiguous.

3 Likes