Skip to content

Commit

Permalink
fix #29781, disallow spaces in broadcast calls (#30182)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Nov 29, 2018
1 parent 15f649c commit 8012ba1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Language changes

* Parser inputs ending with a comma are now consistently treated as incomplete.
Previously they were sometimes parsed as tuples, depending on whitespace ([#28506]).
* Spaces were accidentally allowed in broadcast call syntax, e.g. `f. (x)`. They are now
disallowed, consistent with normal function call syntax ([#29781]).
* Big integer literals and command syntax (backticks) are now parsed with the name of
the macro (`@int128_str`, `@uint128_str`, `@big_str`, `@cmd`) qualified to refer
to the `Core` module ([#29968]).
Expand Down
3 changes: 3 additions & 0 deletions src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,9 @@
(loop
(cond ((eqv? (peek-token s) #\()
(begin
(if (ts:space? s)
(error (string "space before \"(\" not allowed in \""
(deparse ex) ". (\"")))
(take-token s)
`(|.| ,ex (tuple ,@(parse-call-arglist s #\) )))))
((eqv? (peek-token s) ':)
Expand Down
2 changes: 2 additions & 0 deletions test/syntax.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1328,6 +1328,8 @@ end
@test Meta.parse("+((1,2))") == Expr(:call, :+, Expr(:tuple, 1, 2))

@test_throws ParseError("space before \"(\" not allowed in \"+ (\"") Meta.parse("1 -+ (a=1, b=2)")
# issue #29781
@test_throws ParseError("space before \"(\" not allowed in \"sin. (\"") Meta.parse("sin. (1)")

@test Meta.parse("1 -+(a=1, b=2)") == Expr(:call, :-, 1,
Expr(:call, :+, Expr(:kw, :a, 1), Expr(:kw, :b, 2)))
Expand Down

0 comments on commit 8012ba1

Please sign in to comment.