Skip to content

Commit

Permalink
Merge pull request #21787 from JuliaLang/jb/fix20575
Browse files Browse the repository at this point in the history
fix #20575, syntax error for juxtaposing a string literal
  • Loading branch information
JeffBezanson committed May 17, 2017
2 parents 64a230b + 169daa4 commit b7d6be0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ This section lists changes that do not have deprecation warnings.
* `ntuple(f, n::Integer)` throws `ArgumentError` if `n` is negative.
Previously an empty tuple was returned ([#21697]).

* Juxtaposing string literals (e.g. `"x"y`) is now a syntax error ([#20575]).

* `@__DIR__` returns the current working directory rather than `nothing` when not run
from a file ([#21759]).

Expand Down
4 changes: 3 additions & 1 deletion src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -876,9 +876,11 @@
)
(not (ts:space? s))
(not (operator? t))
(not (initial-reserved-word? t))
(not (closing-token? t))
(not (newline? t))
(or (not (string? expr)) ;; issue #20575
(error "cannot juxtapose string literal"))
(not (initial-reserved-word? t))
(not (and (pair? expr) (syntactic-unary-op? (car expr))))
;; TODO: this would disallow juxtaposition with 0, which is ambiguous
;; with e.g. hex literals `0x...`. however this is used for `0im`, which
Expand Down
4 changes: 4 additions & 0 deletions test/parse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,10 @@ f21586(; @m21586(a), @m21586(b)) = a + b
end
@test Test21604.X(1.0) === Test21604.X(1.0)

# issue #20575
@test_throws ParseError parse("\"a\"x")
@test_throws ParseError parse("\"a\"begin end")

# comment 298107224 on pull #21607
module Test21607
using Base.Test
Expand Down

2 comments on commit b7d6be0

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @jrevels

Please sign in to comment.