Skip to content

Commit

Permalink
Fix bug in formatting of export/public expressions with interpolated …
Browse files Browse the repository at this point in the history
…vars
  • Loading branch information
fredrikekre committed Jul 24, 2024
1 parent 948f2d3 commit 3645072
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/runestone.jl
Original file line number Diff line number Diff line change
Expand Up @@ -974,12 +974,15 @@ function spaces_in_export_public(ctx::Context, node::Node)
state = :expect_identifier
elseif state === :expect_identifier
state = :expect_comma
if kind(kid) in KSet"Identifier @ MacroName"
if kind(kid) in KSet"Identifier @ MacroName $"
any_changes && push!(kids′, kid)
accept_node!(ctx, kid)
if kind(kid) === K"@"
state = :expect_identifier
end
if kind(kid) === K"$"
@assert findlast(x -> x === K"quote", ctx.lineage_kinds) !== nothing
end
else
@assert false
end
Expand Down
6 changes: 5 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Runic:
Runic, format_string
using Test:
@test, @testset, @test_broken, @inferred
@test, @testset, @test_broken, @inferred, @test_throws
using JuliaSyntax:
JuliaSyntax

Expand Down Expand Up @@ -809,6 +809,10 @@ end
@test format_string("$(verb) $(a)$(sp),\n$(b)") == "$(verb) $(a),\n $(b)"
@test format_string("$(verb) \n$(a)$(sp),\n$(b)") == "$(verb)\n $(a),\n $(b)"
end
# Interpolated identifiers (currently only expected in K"quote")
@test format_string(":(export \$a)") == ":(export \$a)"
@test format_string("quote\nexport \$a, \$b\nend") == "quote\n export \$a, \$b\nend"
@test_throws Exception format_string("export \$a")
end

@testset "parsing new syntax" begin
Expand Down

0 comments on commit 3645072

Please sign in to comment.