Skip to content

Commit ec80011

Browse files
authored
Merge pull request #18256 from ihnorton/fix18002
Fix #18002: parse `typealias` args space-sensitive
2 parents 7a49be2 + 143672e commit ec80011

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/julia-parser.scm

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,11 +1218,8 @@
12181218
(list 'bitstype (with-space-sensitive (parse-cond s))
12191219
(parse-subtype-spec s)))
12201220
((typealias)
1221-
(let ((lhs (parse-call s)))
1222-
(if (and (pair? lhs) (eq? (car lhs) 'call))
1223-
;; typealias X (...) is tuple type alias, not call
1224-
(list 'typealias (cadr lhs) (cons 'tuple (cddr lhs)))
1225-
(list 'typealias lhs (parse-arrow s)))))
1221+
(let ((lhs (with-space-sensitive (parse-call s))))
1222+
(list 'typealias lhs (parse-arrow s))))
12261223
((try)
12271224
(let ((try-block (if (memq (require-token s) '(catch finally))
12281225
'(block)

test/parse.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,3 +818,8 @@ type Type
818818
end
819819
end
820820
@test method_exists(Mod18756.Type, ())
821+
822+
# issue 18002
823+
@test parse("typealias a (Int)") == Expr(:typealias, :a, :Int)
824+
@test parse("typealias b (Int,)") == Expr(:typealias, :b, Expr(:tuple, :Int))
825+
@test parse("typealias Foo{T} Bar{T}") == Expr(:typealias, Expr(:curly, :Foo, :T), Expr(:curly, :Bar, :T))

0 commit comments

Comments
 (0)