Browse Source

Fix interpolated vars as `as`-aliases

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

8
src/runestone.jl

@ -1106,7 +1106,13 @@ function format_as(ctx::Context, node::Node)
# Alias-identifier # Alias-identifier
idx += 1 idx += 1
kid = kids[idx] kid = kids[idx]
@assert kind(kid) === K"Identifier" @assert kind(kid) in KSet"Identifier $"
if !is_leaf(kid)
@assert kind(first_leaf(kid)) !== K"Whitespace"
end
if kind(kid) === K"$"
@assert findlast(x -> x in KSet"quote macrocall", ctx.lineage_kinds) !== nothing
end
accept_node!(ctx, kid) accept_node!(ctx, kid)
any_changes && push!(kids′, kid) any_changes && push!(kids′, kid)
# Reset stream # Reset stream

4
test/runtests.jl

@ -825,6 +825,10 @@ end
"$(verb) A: a, c as d" "$(verb) A: a, c as d"
end end
end end
# Interpolated aliases in quotes and macrocalls
@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"
end end
@testset "spaces in export/public" begin @testset "spaces in export/public" begin

Loading…
Cancel
Save