JuliaLang / JuliaLang/JuliaSyntax.jl

Begining blocks with colons

Open
#354 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
293
Forks
50
PR merge metrics
No merged PRs in 30d

Description

Python users moving to Julia often make a mistake like this:
```julia
julia> for i in randint(3): # includes colon
println(i)
# no `end`
ERROR: ParseError:
# Error @ REPL[4]:1:21
# ┌
for i in randint(3):
println(i)
#──┘ ── line break after `:` in range expression
# Error @ REPL[4]:2:15
for i in randint(3):
println(i)
# └ ── Expected `end`
```
Ideally, the error message should explain that colons aren't needed at the start of a block, and that `end` blocks are.

```julia
julia> for i in randint(3): # includes colon
println(i)
ERROR: ParseError:
# Error @ REPL[4]:1:21
# ┌
for i in randint(3):
println(i)
#──┘ ── Colon (`:`) not needed to begin blocks
# Error @ REPL[4]:2:15
for i in randint(3):
println(i)
# └ ── `for` blocks must be closed with `end` keyword
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.