Skip to content

Commit fba188c

Browse files
stevengjJeffBezanson
authored andcommitted
allow @foo{...} macro calls (#34505)
1 parent a5c422f commit fba188c

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

NEWS.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Julia v1.5 Release Notes
33

44
New language features
55
---------------------
6-
6+
* Macro calls `@foo {...}` can now also be written `@foo{...}` (without the space) ([#34498]).
77

88
Language changes
99
----------------

src/julia-parser.scm

+4-1
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,10 @@
12411241
((#\{ )
12421242
(disallow-space s ex t)
12431243
(take-token s)
1244-
(loop (list* 'curly ex (parse-call-arglist s #\} ))))
1244+
(let ((args (parse-call-arglist s #\} )))
1245+
(if macrocall?
1246+
`(call ,ex (braces ,@args))
1247+
(loop (list* 'curly ex args)))))
12451248
((#\" #\`)
12461249
(if (and (or (symbol? ex) (valid-modref? ex))
12471250
(not (operator? ex))

test/parse.jl

+11
Original file line numberDiff line numberDiff line change
@@ -364,3 +364,14 @@ end
364364
@test expr == Meta.parse(pf > pg ? "(x$(f)y)$(g)z" : "x$(f)(y$(g)z)")
365365
end
366366
end
367+
368+
# issue 34498
369+
@testset "macro calls @foo{...}" begin
370+
@test :(@foo{}) == :(@foo {})
371+
@test :(@foo{bar}) == :(@foo {bar})
372+
@test :(@foo{bar,baz}) == :(@foo {bar,baz})
373+
@test :(@foo{bar}(baz)) == :((@foo{bar})(baz))
374+
@test :(@foo{bar}{baz}) == :((@foo{bar}){baz})
375+
@test :(@foo{bar}[baz]) == :((@foo{bar})[baz])
376+
@test :(@foo{bar} + baz) == :((@foo{bar}) + baz)
377+
end

0 commit comments

Comments
 (0)