From e5c23b866929628918fe207cb1a2402a6fe39d1a Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Wed, 18 Mar 2026 12:59:24 +0100 Subject: [PATCH] ABI export: output unnamed arguments as null Co-Authored-By: Claude Sonnet 4.6 --- src/abi_export.jl | 4 +++- test/cli.jl | 4 ++++ test/libsimple.jl | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/abi_export.jl b/src/abi_export.jl index c62e36f..1ab247a 100644 --- a/src/abi_export.jl +++ b/src/abi_export.jl @@ -162,7 +162,9 @@ function emit_method_info!(ctx::TypeEmitter, method::Core.Method; indent::Int = for i in 2:length(sig.parameters) print(ctx.io, " " ^ (indent + 4)) print(ctx.io, "{") - print(ctx.io, " \"name\": ", escape_string_json(argnames[i]), ",") + argname = argnames[i] + name_json = argname == "#unused#" ? "null" : escape_string_json(argname) + print(ctx.io, " \"name\": ", name_json, ",") print(ctx.io, " \"type_id\": ", ctx.type_ids[sig.parameters[i]]) println(ctx.io, i == length(sig.parameters) ? " }" : " },") end diff --git a/test/cli.jl b/test/cli.jl index ce126c1..5e4e802 100644 --- a/test/cli.jl +++ b/test/cli.jl @@ -113,6 +113,10 @@ end # `Ptr{CTree{Float64}}` should refer (recursively) back to the original type id Ptr_CTree_Float64 = abi["types"][CVector_CTree_Float64["fields"][2]["type_id"]] @test Ptr_CTree_Float64["pointee_type_id"] == CTree_Float64_id + + # Unnamed argument names should be exported as empty strings + unnamed = abi["functions"][findfirst(x -> x["symbol"] == "unnamed_arguments", abi["functions"])::Int] + @test all(isnothing, arg["name"] for arg in unnamed["arguments"]) end @testset "CLI library privatize end-to-end" begin diff --git a/test/libsimple.jl b/test/libsimple.jl index 64126ff..7925854 100644 --- a/test/libsimple.jl +++ b/test/libsimple.jl @@ -45,6 +45,10 @@ Base.@ccallable function countsame(list::Ptr{MyTwoVec}, n::Int32)::Int32 return count end +Base.@ccallable function unnamed_arguments(::Int32, _::Int32)::Int32 + return 0 +end + export countsame, copyto_and_sum # FIXME? varargs