Browse Source

Fix bug in formatting of export/public expressions with interpolated vars

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

5
src/runestone.jl

@ -974,12 +974,15 @@ function spaces_in_export_public(ctx::Context, node::Node) @@ -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

6
test/runtests.jl

@ -3,7 +3,7 @@ @@ -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
@ -809,6 +809,10 @@ end @@ -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

Loading…
Cancel
Save