From 202fb57a6bcd7d372dcaba4e54d13ca5ab3abb76 Mon Sep 17 00:00:00 2001 From: "Steven G. Johnson" Date: Mon, 27 Jan 2020 22:57:18 -0500 Subject: [PATCH] allow @foo{...} macro calls (#34505) --- NEWS.md | 2 +- src/julia-parser.scm | 5 ++++- test/parse.jl | 11 +++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index 5ff1e44e42fe8..723819f15cbd4 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 ---------------- diff --git a/src/julia-parser.scm b/src/julia-parser.scm index 86f0c8494f7aa..28e6146fdcf61 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -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)) diff --git a/test/parse.jl b/test/parse.jl index 249d537bc1817..bd29c2c77b027 100644 --- a/test/parse.jl +++ b/test/parse.jl @@ -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