Skip to content

Commit

Permalink
Merge pull request JuliaLang#12045 from JuliaLang/jcb/12027
Browse files Browse the repository at this point in the history
check macro identifier length before calling string.dec
  • Loading branch information
jakebolewski committed Jul 9, 2015
2 parents e8c52d7 + 30529d3 commit 083dc41
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -2072,9 +2072,11 @@
(or (simple-string-literal? e)
(and (length= e 3) (eq? (car e) 'macrocall)
(simple-string-literal? (caddr e))
(let ((mname (string (cadr e))))
(equal? (string.sub mname (string.dec mname (length mname) 4))
"_str")))))
(let* ((mname (string (cadr e)))
(len (length mname)))
(and (> len 4)
(equal? (string.sub mname (string.dec mname len 4))
"_str"))))))

(define (parse-docstring s production)
(let* ((isstr (eqv? (peek-token s) #\"))
Expand Down
7 changes: 7 additions & 0 deletions test/parser.jl
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,10 @@ macro test999_str(args...); args; end
@test parseall("a = \$\nb") == Expr(:block, Expr(:(=), :a, :$), :b)
@test parseall(":(a = &\nb)") == Expr(:quote, Expr(:(=), :a, Expr(:&, :b)))
@test parseall(":(a = \$\nb)") == Expr(:quote, Expr(:(=), :a, Expr(:$, :b)))

# issue 11970
@test parseall("""
macro f(args...) end; @f ""
""") == Expr(:toplevel,
Expr(:macro, Expr(:call, :f, Expr(:..., :args)), Expr(:block,)),
Expr(:macrocall, symbol("@f"), ""))

0 comments on commit 083dc41

Please sign in to comment.