Hello everyone,
I’m using Julia through VS Code and I often face an issue regarding “end” statements (at least for Ubuntu 20.04) when using the REPL. The problem seems to be that if there are two consecutive empty lines, then the code seems to be evaluated in 2 separate parts, which throws an error.
For instance, the following works:
function test()
a = 2
b = 3
end
But this does not:
function test()
a = 2
b = 3
end
julia> function test()
a = 2
ERROR: syntax: incomplete: "function" at REPL[7]:1 requires end
Stacktrace:
[1] top-level scope
@ none:1
julia> b = 3
3
julia> end
ERROR: syntax: unexpected "end"
Stacktrace:
[1] top-level scope
@ none:1
The above was for a function, the following is with for loop. Again, this works:
for i = 1:5
x = 2
println("$i")
end
But this does not:
for i = 1:5
x = 2
println("$i")
end
julia> for i = 1:5
x = 2
ERROR: syntax: incomplete: "for" at REPL[2]:1 requires end
Stacktrace:
[1] top-level scope
@ none:1
julia> println("$i")
ERROR: UndefVarError: i not defined
Stacktrace:
[1] top-level scope
@ REPL[3]:1
julia>
julia> end
ERROR: syntax: unexpected "end"
Stacktrace:
[1] top-level scope
@ none:1
Indenting the code does not change anything either.
The weird thing is that it does not happen every time, but does happen fairly often. So I’m not sure how seriously everyone here should take it. I’m posting this in case anyone else has had the same problem.
Note that this happens both when I’m giving the code directly to the terminal from VS Code, or activating the Julia-VS Code environment (via the Julia extension for VS Code) then sending it to the terminal. It might be a Ubuntu 20.04 issue though, so I’d be curious to know if this happens in other OS.