Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@

(define initial-reserved-words '(begin while if for try return break continue
function macro quote let local global const do
struct
struct mutable
abstract typealias bitstype type immutable ;; to be deprecated
module baremodule using import export importall))

Expand Down Expand Up @@ -1005,7 +1005,7 @@
;; also handles looking for syntactic reserved words
(define (parse-call s)
(let ((ex (parse-unary-prefix s)))
(if (or (initial-reserved-word? ex) (memq ex '(mutable primitive)))
(if (or (initial-reserved-word? ex) (eq? ex 'primitive))
(parse-resword s ex)
(parse-call-chain s ex #f))))

Expand Down Expand Up @@ -1320,10 +1320,9 @@
(begin (take-token s)
(parse-struct-def s #f word)))
((mutable)
(if (not (eq? (peek-token s) 'struct))
(parse-call-chain s word #f)
(begin (take-token s)
(parse-struct-def s #t word))))
(if (eq? (peek-token s) 'struct)
(take-token s))
(parse-struct-def s #t word))
((primitive)
(if (not (eq? (peek-token s) 'type))
(parse-call-chain s word #f)
Expand Down
17 changes: 17 additions & 0 deletions test/parse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1215,3 +1215,20 @@ end
# issue #19351
# adding return type decl should not affect parse of function body
@test :(t(abc) = 3).args[2] == :(t(abc)::Int = 3).args[2]

# Optional `struct` in `mutable struct`
let
mutsct = """
mutable struct Enterprise <: Starship
captain::String
end
"""
mut = """
mutable Enterprise <: Starship
captain::String
end
"""
@test parse(mutsct) == parse(mut)
# Ensure we haven't broken the `T.mutable` field for types
@test !Int.mutable
end