Skip to content

Commit

Permalink
allow @foo{...} macro calls (#34505)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevengj authored and JeffBezanson committed Jan 28, 2020
1 parent a5c422f commit fba188c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
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

2 comments on commit fba188c

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

Please sign in to comment.