Skip to content

Commit b31501b

Browse files
Dale-Blackclaude
andcommitted
Fix kwcall handling: resolve via SSA callee, add :plotly registration
Core.kwcall appears as SSA callee in unoptimized IR, not GlobalRef. Added detection in SSA resolver. Also register :plotly name alongside :plot. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4a4c269 commit b31501b

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

src/compiler/codegen.jl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,35 @@ function compile_call(ctx::JSCompilationContext, expr::Expr)
779779
fn_name = string(nameof(resolved_fn))
780780
call_args = [compile_value(ctx, a) for a in args[2:end]]
781781

782+
# Handle Core.kwcall — keyword argument function calls
783+
if resolved_fn === Core.kwcall && length(args) >= 3
784+
kwargs_ssa = args[2]
785+
func_ssa = args[3]
786+
pos_raw = args[4:end]
787+
788+
func_type = nothing
789+
if func_ssa isa Core.SSAValue
790+
func_type = ctx.code_info.ssavaluetypes[func_ssa.id]
791+
end
792+
793+
if func_type isa Core.Const
794+
fn = func_type.val
795+
fn_mod = parentmodule(fn)
796+
fn_sym = nameof(fn)
797+
compiler_fn = lookup_package_compilation(fn_mod, fn_sym)
798+
if compiler_fn !== nothing
799+
kwargs = _extract_kwargs(ctx, kwargs_ssa)
800+
pos_args_kw = [compile_value(ctx, a) for a in pos_raw]
801+
return compiler_fn(ctx, kwargs, pos_args_kw)
802+
end
803+
end
804+
805+
# Fallback for unregistered kwcall
806+
func_js = compile_value(ctx, func_ssa)
807+
pos_compiled = [compile_value(ctx, a) for a in pos_raw]
808+
return "$(func_js)($(join(pos_compiled, ", ")))"
809+
end
810+
782811
# Check package registry for positional calls
783812
if resolved_fn isa Function
784813
fn_mod = parentmodule(resolved_fn)

src/compiler/packages_plotly.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,7 @@ function register_plotly_compilations!(mod::Module)
7373
if isdefined(mod, :plot)
7474
register_package_compilation!(_plotly_plot_compiler, mod, :plot)
7575
end
76+
if isdefined(mod, :plotly)
77+
register_package_compilation!(_plotly_plot_compiler, mod, :plotly)
78+
end
7679
end

0 commit comments

Comments
 (0)