From 826a5662159e76408ad859d78ed93a6c9001acae Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Mon, 8 Jul 2024 17:30:33 +0200 Subject: [PATCH] Fix empty functions with Unicode symbol names --- src/runestone.jl | 4 +++- test/runtests.jl | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/runestone.jl b/src/runestone.jl index b65b429..b6a4baa 100644 --- a/src/runestone.jl +++ b/src/runestone.jl @@ -1348,7 +1348,9 @@ function indent_function_or_macro(ctx::Context, node::Node) @assert is_longform_anon_function(node) end sig_node = kids[sig_idx] - if kind(sig_node) === K"Identifier" + # Identifier for regular names but "not function call" for empty functions with Unicode + # symbols?? + if kind(sig_node) === K"Identifier" || !(kind(sig_node) in KSet"call where :: tuple") # Empty function definition like `function f end`. # TODO: Make sure the spaces around are correct end_idx = findnext(x -> kind(x) === K"end", kids, sig_idx + 1)::Int diff --git a/test/runtests.jl b/test/runtests.jl index c338130..7b69d4b 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -464,6 +464,7 @@ end @test format_string("function f()\n$(sp)x\n$(sp)end") == "function f()\n x\nend" @test format_string("function f end") == "function f end" + @test format_string("function ∉ end") == "function ∉ end" # macro-end @test format_string("macro f()\n$(sp)x\n$(sp)end") == "macro f()\n x\nend"