# "Unexpected end" issue when extra line gap in code

**URL:** https://discourse.julialang.org/t/unexpected-end-issue-when-extra-line-gap-in-code/66296
**Category:** VS Code
**Created:** [August 12, 2021, 8:52pm UTC](https://discourse.julialang.org/t/unexpected-end-issue-when-extra-line-gap-in-code/66296 "2021-08-12T20:52:39Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![rubaiyat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rubaiyat/32/27423_2.png) [@rubaiyat](https://discourse.julialang.org/u/rubaiyat)
#### Post date: [August 12, 2021, 8:52pm UTC](https://discourse.julialang.org/t/unexpected-end-issue-when-extra-line-gap-in-code/66296/1 "2021-08-12T20:52:39Z")

</div>

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:

```julia

function test()

a = 2

b = 3

end

```

But this does not:

```julia

function test()

a = 2

b = 3

end

```

```julia
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:

```julia

for i = 1:5

x = 2

println("$i")

end

```

But this does not:

```julia

for i = 1:5

x = 2

println("$i")

end

```

```julia
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.

---

<div class="post-metadata">

### Author: ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)
#### Post date: [August 12, 2021, 8:55pm UTC](https://discourse.julialang.org/t/unexpected-end-issue-when-extra-line-gap-in-code/66296/2 "2021-08-12T20:55:56Z")

</div>

I can reproduce this without VSCode by entering this:

```julia
julia> function test()                                          
                                                                
       a = 2                                                    
                                                                
                                                                
ERROR: syntax: incomplete: "function" at REPL[17]:1 requires end
Stacktrace:                                                     
 [1] top-level scope                                            
   @ none:1                                                     

```

directly into the REPL. That is,`function test()` followed by newline, newline, then `a = 2`, followed by newline, newline, newline. The last new line throws the error. ~~Seems like a genuine bug.~~

~~Please open an issue at [GitHub - JuliaLang/julia: The Julia Programming Language](http://github.com/julialang/julia)!~~

---

<div class="post-metadata">

### Author: ![mzaffalon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mzaffalon/32/214168_2.png) [@mzaffalon](https://discourse.julialang.org/u/mzaffalon)
#### Post date: [August 12, 2021, 9:15pm UTC](https://discourse.julialang.org/t/unexpected-end-issue-when-extra-line-gap-in-code/66296/3 "2021-08-12T21:15:38Z")

</div>

It was already discussed [here](https://discourse.julialang.org/t/multiline-input-and-whitespace/7020). The relevant section of the manual is at [The Julia REPL · The Julia Language](https://docs.julialang.org/en/v1/stdlib/REPL/#Key-bindings).

---

<div class="post-metadata">

### Author: ![rubaiyat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rubaiyat/32/27423_2.png) [@rubaiyat](https://discourse.julialang.org/u/rubaiyat)
#### Post date: [August 12, 2021, 9:50pm UTC](https://discourse.julialang.org/t/unexpected-end-issue-when-extra-line-gap-in-code/66296/4 "2021-08-12T21:50:49Z")

</div>

Oops, hadn’t seen that post somehow. Thanks!
