Browse Source

Allow interpolated vars in export lists inside macrocalls

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

2
src/runestone.jl

@ -981,7 +981,7 @@ function spaces_in_export_public(ctx::Context, node::Node)
state = :expect_identifier state = :expect_identifier
end end
if kind(kid) === K"$" if kind(kid) === K"$"
@assert findlast(x -> x === K"quote", ctx.lineage_kinds) !== nothing @assert findlast(x -> x in KSet"quote macrocall", ctx.lineage_kinds) !== nothing
end end
elseif kind(kid) in KSet"Comment NewlineWs" elseif kind(kid) in KSet"Comment NewlineWs"
any_changes && push!(kids′, kid) any_changes && push!(kids′, kid)

3
test/runtests.jl

@ -836,9 +836,10 @@ end
@test format_string("$(verb) \n$(a)$(sp),\n$(b)") == "$(verb)\n $(a),\n $(b)" @test format_string("$(verb) \n$(a)$(sp),\n$(b)") == "$(verb)\n $(a),\n $(b)"
@test format_string("$(verb) $(a)$(sp),\n# b\n$(b)") == "$(verb) $(a),\n # b\n $(b)" @test format_string("$(verb) $(a)$(sp),\n# b\n$(b)") == "$(verb) $(a),\n # b\n $(b)"
end end
# Interpolated identifiers (currently only expected in K"quote") # Interpolated identifiers (currently only expected in K"quote" and K"macrocall")
@test format_string(":(export \$a)") == ":(export \$a)" @test format_string(":(export \$a)") == ":(export \$a)"
@test format_string("quote\nexport \$a, \$b\nend") == "quote\n export \$a, \$b\nend" @test format_string("quote\nexport \$a, \$b\nend") == "quote\n export \$a, \$b\nend"
@test format_string("@eval export \$a") == "@eval export \$a"
@test_throws Exception format_string("export \$a") @test_throws Exception format_string("export \$a")
# Non-identifiers # Non-identifiers
@test format_string("export ^, var\"x\"") == "export ^, var\"x\"" @test format_string("export ^, var\"x\"") == "export ^, var\"x\""

Loading…
Cancel
Save