Skip to content

Commit

Permalink
fix #12755, +((1,2)) should call + with one tuple argument
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Aug 23, 2015
1 parent 9b30678 commit 56360a7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@
(error (string "unexpected " t)))
;; TODO: ? should probably not be listed here except for the syntax hack in osutils.jl
(cond ((and (operator? t) (not (memq t '(: |'| ?))) (not (syntactic-unary-op? t))
(not (invalid-identifier-name? t)))
(not (invalid-identifier-name? t)))
(let* ((op (take-token s))
(nch (peek-char (ts:port s))))
(if (and (or (eq? op '-) (eq? op '+))
Expand All @@ -870,19 +870,14 @@
(let ((next (peek-token s)))
(cond ((or (closing-token? next) (newline? next) (eq? next '=))
op) ; return operator by itself, as in (+)
((or (eqv? next #\{) ;; this case is +{T}(x::T) = ...
(and (not (memq op unary-ops))
(eqv? next #\( )))
((or (eqv? next #\{) ;; +{T}(x::T) or +(x)
(eqv? next #\( ))
(ts:put-back! s op)
(parse-factor s))
((not (memq op unary-ops))
(error (string "\"" op "\" is not a unary operator")))
((not (memq op unary-ops))
(error (string "\"" op "\" is not a unary operator")))
(else
(let ((arg (parse-unary s)))
(if (and (pair? arg)
(eq? (car arg) 'tuple))
(list* 'call op (cdr arg))
(list 'call op arg)))))))))
(list 'call op (parse-unary s))))))))
(else
(parse-juxtapose (parse-factor s) s)))))

Expand Down
4 changes: 4 additions & 0 deletions test/parse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,7 @@ parse("""
# issue #12626
@test parse("a .÷ 1") == Expr(:call, :, :a, 1)
@test parse("a .÷= 1") == Expr(:.÷=, :a, 1)

# issue #12755
@test string(parse(string(:((+)((1,2)))))) == "+((1,2))"
@test string(parse(string(:((~)((1,2)))))) == "~((1,2))"

0 comments on commit 56360a7

Please sign in to comment.