Skip to content

Commit

Permalink
Add nkw meta to keyword function bodies
Browse files Browse the repository at this point in the history
  • Loading branch information
c42f committed Feb 1, 2025
1 parent bd6b7bb commit a8aa478
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
7 changes: 6 additions & 1 deletion src/desugaring.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2684,7 +2684,12 @@ function keyword_function_defs(ctx, srcref, callex_srcref, name_str,
[K"block"
# TODO: nkw
method_def_expr(ctx, srcref, callex_srcref, "nothing"::K"core",
typevar_names, body_arg_names, body_arg_types, body, ret_var)
typevar_names, body_arg_names, body_arg_types,
[K"block"
[K"meta" "nkw"::K"Symbol" numchildren(keywords)::K"Integer"]
body
],
ret_var)
]
]
[K"method_defs"
Expand Down
24 changes: 14 additions & 10 deletions test/functions_ir.jl
Original file line number Diff line number Diff line change
Expand Up @@ -991,8 +991,9 @@ end
14 (call core.svec %₁₁ %₁₂ %₁₃)
15 --- method core.nothing %₁₄
slots: [slot₁/#self#(!read) slot₂/x slot₃/y slot₄/#self#(!read) slot₅/a slot₆/b]
1 (call core.tuple slot₅/a slot₆/b slot₂/x slot₃/y)
2 (return %₁)
1 (meta :nkw 2)
2 (call core.tuple slot₅/a slot₆/b slot₂/x slot₃/y)
3 (return %₂)
16 (call core.typeof core.kwcall)
17 TestMod.f_kw_simple
18 (call core.Typeof %₁₇)
Expand Down Expand Up @@ -1123,8 +1124,9 @@ end
11 (call core.svec %%%₁₀)
12 --- method core.nothing %₁₁
slots: [slot₁/#self#(!read) slot₂/all_kws slot₃/#self#(!read)]
1 slot₂/all_kws
2 (return %₁)
1 (meta :nkw 1)
2 slot₂/all_kws
3 (return %₂)
13 (call core.typeof core.kwcall)
14 TestMod.f_kw_slurp_simple
15 (call core.Typeof %₁₄)
Expand Down Expand Up @@ -1174,8 +1176,9 @@ end
11 (call core.svec %%%₁₀)
12 --- method core.nothing %₁₁
slots: [slot₁/#self#(!read) slot₂/x(!read) slot₃/non_x_kws(!read) slot₄/#self#(!read)]
1 TestMod.all_kws
2 (return %₁)
1 (meta :nkw 2)
2 TestMod.all_kws
3 (return %₂)
13 (call core.typeof core.kwcall)
14 TestMod.f_kw_slurp
15 (call core.Typeof %₁₄)
Expand Down Expand Up @@ -1248,10 +1251,11 @@ end
17 (call core.svec %₁₂ %₁₅ %₁₆)
18 --- method core.nothing %₁₇
slots: [slot₁/#self#(!read) slot₂/a(!read) slot₃/b(!read) slot₄/#self#(!read) slot₅/x(!read)]
1 static_parameter₁
2 static_parameter₂
3 (call core.tuple %%₂)
4 (return %₃)
1 (meta :nkw 2)
2 static_parameter₁
3 static_parameter₂
4 (call core.tuple %%₃)
5 (return %₄)
19 (call core.typeof core.kwcall)
20 TestMod.f_kw_sparams
21 (call core.Typeof %₂₀)
Expand Down

0 comments on commit a8aa478

Please sign in to comment.