diff --git a/src/runestone.jl b/src/runestone.jl index 1a1d8d7..b4702ec 100644 --- a/src/runestone.jl +++ b/src/runestone.jl @@ -1106,7 +1106,7 @@ function format_as(ctx::Context, node::Node) # Alias-identifier idx += 1 kid = kids[idx] - @assert kind(kid) in KSet"Identifier $" + @assert kind(kid) in KSet"Identifier $ @" if !is_leaf(kid) @assert kind(first_leaf(kid)) !== K"Whitespace" end @@ -1115,6 +1115,13 @@ function format_as(ctx::Context, node::Node) end accept_node!(ctx, kid) any_changes && push!(kids′, kid) + if kind(kid) === K"@" + idx += 1 + kid = kids[idx] + @assert kind(kid) === K"MacroName" + accept_node!(ctx, kid) + any_changes && push!(kids′, kid) + end # Reset stream seek(ctx.fmt_io, pos) return any_changes ? make_node(node, kids′) : nothing diff --git a/test/runtests.jl b/test/runtests.jl index 9ec3181..0ac6e29 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -829,6 +829,8 @@ end @test format_string("quote\nimport A as \$a\nend") == "quote\n import A as \$a\nend" @test format_string(":(import A as \$a)") == ":(import A as \$a)" @test format_string("@eval import A as \$a") == "@eval import A as \$a" + # Macro-aliases + @test format_string("import A.@a as @b") == "import A.@a as @b" end @testset "spaces in export/public" begin