Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow @foo{...} macro calls #34505

Merged
merged 4 commits into from
Jan 28, 2020
Merged
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
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Julia v1.5 Release Notes

New language features
---------------------

* Macro calls `@foo {...}` can now also be written `@foo{...}` (without the space) ([#34498]).

Language changes
----------------
Expand Down
5 changes: 4 additions & 1 deletion src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,10 @@
((#\{ )
(disallow-space s ex t)
(take-token s)
(loop (list* 'curly ex (parse-call-arglist s #\} ))))
(let ((args (parse-call-arglist s #\} )))
(if macrocall?
`(call ,ex (braces ,@args))
(loop (list* 'curly ex args)))))
((#\" #\`)
(if (and (or (symbol? ex) (valid-modref? ex))
(not (operator? ex))
Expand Down
11 changes: 11 additions & 0 deletions test/parse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -364,3 +364,14 @@ end
@test expr == Meta.parse(pf > pg ? "(x$(f)y)$(g)z" : "x$(f)(y$(g)z)")
end
end

# issue 34498
@testset "macro calls @foo{...}" begin
@test :(@foo{}) == :(@foo {})
@test :(@foo{bar}) == :(@foo {bar})
@test :(@foo{bar,baz}) == :(@foo {bar,baz})
@test :(@foo{bar}(baz)) == :((@foo{bar})(baz))
@test :(@foo{bar}{baz}) == :((@foo{bar}){baz})
@test :(@foo{bar}[baz]) == :((@foo{bar})[baz])
@test :(@foo{bar} + baz) == :((@foo{bar}) + baz)
end