Skip to content

Commit 4b4fb1e

Browse files
abap34aviatesk
andauthored
Do not treat static parameter as is_always_defined (#41)
Co-authored-by: Shuhei Kadowaki <[email protected]>
1 parent eb90f64 commit 4b4fb1e

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

src/scope_analysis.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ function add_lambda_args(ctx, var_ids, args, args_kind)
194194
"static parameter name not distinct from function argument"
195195
throw(LoweringError(arg, msg))
196196
end
197-
is_always_defined = args_kind == :argument || args_kind == :static_parameter
197+
is_always_defined = args_kind == :argument
198198
id = init_binding(ctx, arg, varkey, args_kind;
199199
is_nospecialize=getmeta(arg, :nospecialize, false),
200200
is_always_defined=is_always_defined)

test/closures_ir.jl

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ end
206206
1 (method TestMod.f)
207207
2 latestworld
208208
3 (call core.svec :T)
209-
4 (call core.svec false)
209+
4 (call core.svec true)
210210
5 (call JuliaLowering.eval_closure_type TestMod :#f#g##2 %₃ %₄)
211211
6 latestworld
212212
7 TestMod.#f#g##2
@@ -215,11 +215,17 @@ end
215215
10 SourceLocation::2:14
216216
11 (call core.svec %%%₁₀)
217217
12 --- method core.nothing %₁₁
218-
slots: [slot₁/#self#(!read)]
218+
slots: [slot₁/#self#(!read) slot₂/T(!read)]
219219
1 TestMod.use
220220
2 (call core.getfield slot₁/#self# :T)
221-
3 (call %%₂)
222-
4 (return %₃)
221+
3 (call core.isdefined %:contents)
222+
4 (gotoifnot %₃ label₆)
223+
5 (goto label₈)
224+
6 (newvar slot₂/T)
225+
7 slot₂/T
226+
8 (call core.getfield %:contents)
227+
9 (call %%₈)
228+
10 (return %₉)
223229
13 latestworld
224230
14 (= slot₁/T (call core.TypeVar :T))
225231
15 TestMod.f
@@ -234,13 +240,10 @@ end
234240
slots: [slot₁/#self#(!read) slot₂/_(!read) slot₃/g]
235241
1 TestMod.#f#g##2
236242
2 static_parameter₁
237-
3 (call core.typeof %₂)
238-
4 (call core.apply_type %%₃)
239-
5 static_parameter₁
240-
6 (new %%₅)
241-
7 (= slot₃/g %₆)
242-
8 slot₃/g
243-
9 (return %₈)
243+
3 (new %%₂)
244+
4 (= slot₃/g %₃)
245+
5 slot₃/g
246+
6 (return %₅)
244247
24 latestworld
245248
25 TestMod.f
246249
26 (return %₂₅)

test/functions.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,16 @@ end
192192
(1, [1.0], 2, Float64, Vector{Float64}, Int),
193193
(1, [1.0], -1.0, Float64, Vector{Float64}, Float64))
194194

195+
@test JuliaLowering.include_string(test_mod, """
196+
begin
197+
function f_def_typevar_vararg_undef(x::T, y::Vararg{S}) where {T,S}
198+
(x, y, @isdefined S)
199+
end
200+
201+
(f_def_typevar_vararg_undef(1), f_def_typevar_vararg_undef(1,2), f_def_typevar_vararg_undef(1,2,3))
202+
end
203+
""") === ((1, (), false), (1, (2,), true), (1, (2, 3), true))
204+
195205
@test JuliaLowering.include_string(test_mod, """
196206
begin
197207
function f_def_slurp(x=1, ys...)

0 commit comments

Comments
 (0)