From 6d975d35a39add1e2d2e49c99c0c602c68ab65c2 Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Wed, 24 Jul 2024 23:10:47 +0200 Subject: [PATCH] Fix parenthesized macrocalls with keyword arguments --- src/runestone.jl | 4 ++-- test/runtests.jl | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/runestone.jl b/src/runestone.jl index e3b4712..b74e7c2 100644 --- a/src/runestone.jl +++ b/src/runestone.jl @@ -320,7 +320,7 @@ function spaces_in_listlike(ctx::Context, node::Node) end if kind(node) === K"parameters" # Note that some of these are not valid Julia syntax but still parse - @assert ctx.lineage_kinds[end] in KSet"tuple call dotcall curly vect" + @assert ctx.lineage_kinds[end] in KSet"tuple call dotcall macrocall curly vect" end @assert !is_leaf(node) @@ -602,7 +602,7 @@ function spaces_in_listlike(ctx::Context, node::Node) any_kid_changed && push!(kids′, kid′) elseif kind(kid′) === K"parameters" # Note that some of these are not valid Julia syntax still parse - @assert kind(node) in KSet"call dotcall curly tuple vect" + @assert kind(node) in KSet"call dotcall macrocall curly tuple vect" if kind(first_leaf(kid′)) === K"Whitespace" # Delete the whitespace leaf kid_ws = first_leaf(kid′) diff --git a/test/runtests.jl b/test/runtests.jl index 9d527b9..89388f4 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -331,6 +331,12 @@ end # https://github.com/fredrikekre/Runic.jl/issues/16 @test format_string("(i for i in\nI)") == "(\n i for i in\n I\n)" @test format_string("f(i for i in\nI)") == "f(\n i for i in\n I\n)" + # Parenthesized macrocalls with keyword arguments + for sp in ("", " ", " ") + @test format_string("@f($(sp)a$(sp);$(sp)b$(sp))") == "@f(a; b)" + @test format_string("@f($(sp)a$(sp);$(sp)b = 1$(sp))") == "@f(a; b = 1)" + @test format_string("@f($(sp);$(sp)b$(sp))") == "@f(; b)" + end end @testset "whitespace around ->" begin