Browse Source

Fix parenthesized macrocalls with keyword arguments

pull/26/head
Fredrik Ekre 1 year ago
parent
commit
6d975d35a3
No known key found for this signature in database
GPG Key ID: DE82E6D5E364C0A2
  1. 4
      src/runestone.jl
  2. 6
      test/runtests.jl

4
src/runestone.jl

@ -320,7 +320,7 @@ function spaces_in_listlike(ctx::Context, node::Node)
end end
if kind(node) === K"parameters" if kind(node) === K"parameters"
# Note that some of these are not valid Julia syntax but still parse # 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 end
@assert !is_leaf(node) @assert !is_leaf(node)
@ -602,7 +602,7 @@ function spaces_in_listlike(ctx::Context, node::Node)
any_kid_changed && push!(kids′, kid′) any_kid_changed && push!(kids′, kid′)
elseif kind(kid′) === K"parameters" elseif kind(kid′) === K"parameters"
# Note that some of these are not valid Julia syntax still parse # 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" if kind(first_leaf(kid′)) === K"Whitespace"
# Delete the whitespace leaf # Delete the whitespace leaf
kid_ws = first_leaf(kid′) kid_ws = first_leaf(kid′)

6
test/runtests.jl

@ -331,6 +331,12 @@ end
# https://github.com/fredrikekre/Runic.jl/issues/16 # 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("(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)" @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 end
@testset "whitespace around ->" begin @testset "whitespace around ->" begin

Loading…
Cancel
Save