Skip to content

Commit

Permalink
un-deprecate (;) and make it parse to an empty named tuple
Browse files Browse the repository at this point in the history
fixes #30115
  • Loading branch information
JeffBezanson committed Jan 28, 2020
1 parent 4e2a6e7 commit 84d791b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Language changes
(in addition to the one that enters the help mode) to see the full
docstring. ([#25930])

* The syntax `(;)` (which was deprecated in v1.4) now creates an empty named tuple ([#30115]).

Multi-threading changes
-----------------------

Expand Down
4 changes: 1 addition & 3 deletions src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1921,9 +1921,7 @@
(and (null? first) (null? blk)
;; all semicolons inside ()
(if (length= (car args) 1)
(begin (parser-depwarn s "(;)" "begin end")
;; should eventually be (tuple (parameters))
`(block))
`(tuple (parameters))
`(block)))))))
(and (null? first) (null? args) (not comma?)
(error "unreachable"))
Expand Down
4 changes: 2 additions & 2 deletions test/syntax.jl
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ macro test999_str(args...); args; end

# blocks vs. tuples
@test Meta.parse("()") == Expr(:tuple)
@test_skip Meta.parse("(;)") == Expr(:tuple, Expr(:parameters))
@test Meta.parse("(;)") == Expr(:tuple, Expr(:parameters))
@test Meta.parse("(;;;;)") == Expr(:block)
@test_throws ParseError Meta.parse("(,)")
@test_throws ParseError Meta.parse("(;,)")
Expand Down Expand Up @@ -1322,7 +1322,7 @@ end
@test Meta.parse("-(x)^2") == Expr(:call, :-, Expr(:call, :^, :x, 2))
@test Meta.parse("-(a=1)^2") == Expr(:call, :-, Expr(:call, :^, Expr(:(=), :a, 1), 2))
@test Meta.parse("-(x;y)^2") == Expr(:call, :-, Expr(:call, :^, Expr(:block, :x, LineNumberNode(1,:none), :y), 2))
@test_skip Meta.parse("-(;)^2") == Expr(:call, :-, Expr(:call, :^, Expr(:tuple, Expr(:parameters)), 2))
@test Meta.parse("-(;)^2") == Expr(:call, :-, Expr(:call, :^, Expr(:tuple, Expr(:parameters)), 2))
@test Meta.parse("-(;;;;)^2") == Expr(:call, :-, Expr(:call, :^, Expr(:block), 2))
@test Meta.parse("-(x;;;)^2") == Expr(:call, :-, Expr(:call, :^, Expr(:block, :x), 2))
@test Meta.parse("+((1,2))") == Expr(:call, :+, Expr(:tuple, 1, 2))
Expand Down

0 comments on commit 84d791b

Please sign in to comment.