Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/parser.jl
Original file line number Diff line number Diff line change
Expand Up @@ -822,9 +822,10 @@ function parse_range(ps::ParseState)
emit_diagnostic(ps, error="found unexpected closing token")
return
end
if had_newline
if had_newline && !ps.whitespace_newline
Comment thread
pfitzseb marked this conversation as resolved.
Outdated
# Error message for people coming from python
# 1:\n2 ==> (call-i 1 : (error))
# 1:\n2 ==> (call-i 1 : (error))
# (1:\n2) ==> (call-i 1 : 2)
emit_diagnostic(ps, whitespace=true,
error="line break after `:` in range expression")
bump_invisible(ps, K"error")
Expand Down
4 changes: 4 additions & 0 deletions test/parser.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ tests = [
"1:2:3" => "(call-i 1 : 2 3)"
"a:b:c:d:e" => "(call-i (call-i a : b c) : d e)"
"a :< b" => "(call-i a (error : <) b)"
"1:\n2" => "(call-i 1 : (error))"
],
JuliaSyntax.parse_range => [
"a..b" => "(call-i a .. b)"
Expand Down Expand Up @@ -561,6 +562,9 @@ tests = [
# Generators
"(x for a in as)" => "(generator x (= a as))"
"(x \n\n for a in as)" => "(generator x (= a as))"
# Range parsing in parens
"(1:\n2)" => "(call-i 1 : 2)"
"(1:2)" => "(call-i 1 : 2)"
],
JuliaSyntax.parse_atom => [
":foo" => "(quote foo)"
Expand Down