Skip to content

Commit

Permalink
Fix JuliaLang#18002: parse typealias args space-sensitive
Browse files Browse the repository at this point in the history
Also removes hack for the old space-optional call syntax.
  • Loading branch information
ihnorton committed Oct 12, 2016
1 parent 11d3c96 commit 143672e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1218,11 +1218,8 @@
(list 'bitstype (with-space-sensitive (parse-cond s))
(parse-subtype-spec s)))
((typealias)
(let ((lhs (parse-call s)))
(if (and (pair? lhs) (eq? (car lhs) 'call))
;; typealias X (...) is tuple type alias, not call
(list 'typealias (cadr lhs) (cons 'tuple (cddr lhs)))
(list 'typealias lhs (parse-arrow s)))))
(let ((lhs (with-space-sensitive (parse-call s))))
(list 'typealias lhs (parse-arrow s))))
((try)
(let ((try-block (if (memq (require-token s) '(catch finally))
'(block)
Expand Down
5 changes: 5 additions & 0 deletions test/parse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -818,3 +818,8 @@ type Type
end
end
@test method_exists(Mod18756.Type, ())

# issue 18002
@test parse("typealias a (Int)") == Expr(:typealias, :a, :Int)
@test parse("typealias b (Int,)") == Expr(:typealias, :b, Expr(:tuple, :Int))
@test parse("typealias Foo{T} Bar{T}") == Expr(:typealias, Expr(:curly, :Foo, :T), Expr(:curly, :Bar, :T))

0 comments on commit 143672e

Please sign in to comment.