@@ -256,6 +256,7 @@ maybe_step_through_wrapper!(frame::Frame) = maybe_step_through_wrapper!(finish_a
256
256
257
257
const kwhandler = Core. kwcall
258
258
const kwextrastep = 0
259
+ const kw_has_f_first = VERSION . major == 1 && VERSION . minor == 11
259
260
260
261
"""
261
262
frame = maybe_step_through_kwprep!(recurse, frame)
@@ -273,21 +274,29 @@ function maybe_step_through_kwprep!(@nospecialize(recurse), frame::Frame, istopl
273
274
pc, src = frame. pc, frame. framecode. src
274
275
n = length (src. code)
275
276
stmt = pc_expr (frame, pc)
277
+ if isbindingresolved_deprecated && ! isa (stmt, Tuple{Symbol,Vararg{Symbol}}) && ! is_empty_namedtuple (stmt) && n >= pc+ 1
278
+ pc += 1
279
+ stmt = pc_expr (frame, pc)
280
+ elseif kw_has_f_first && pc < n && is_empty_namedtuple (pc_expr (frame, pc+ 1 )) && isa (stmt, QuoteNode)
281
+ pc = step_expr! (recurse, frame, istoplevel)
282
+ stmt = pc_expr (frame, pc)
283
+ end
276
284
if isa (stmt, Tuple{Symbol,Vararg{Symbol}})
277
285
# Check to see if we're creating a NamedTuple followed by kwfunc call
278
- pccall = pc + 4 + kwextrastep
286
+ pccall = pc + 4 + kwextrastep + isbindingresolved_deprecated
279
287
if pccall <= n
280
288
stmt1 = src. code[pc+ 1 ]
281
289
# We deliberately check isexpr(stmt, :call) rather than is_call(stmt): if it's
282
290
# assigned to a local, it's *not* kwarg preparation.
283
- if isexpr (stmt1, :call ) && is_quotenode_egal (stmt1. args[1 ], Core. apply_type) && is_quoted_type (stmt1. args[2 ], :NamedTuple )
284
- stmt4, stmt5 = src. code[pc+ 4 ], src. code[pc+ 5 ]
285
- if isexpr (stmt4, :call ) && is_quotenode_egal (stmt4. args[1 ], kwhandler)
291
+ if isexpr (stmt1, :call ) && ((is_quotenode_egal (stmt1. args[1 ], Core. apply_type) && is_quoted_type (stmt1. args[2 ], :NamedTuple )) ||
292
+ (is_global_ref (stmt1. args[1 ], Core, :apply_type ) && is_global_ref (stmt1. args[2 ], Core, :NamedTuple )))
293
+ stmt4, stmt5 = src. code[pc+ 4 + isbindingresolved_deprecated], src. code[pc+ 5 + isbindingresolved_deprecated]
294
+ if isexpr (stmt4, :call ) && (is_quotenode_egal (stmt4. args[1 ], kwhandler) || is_global_ref (stmt4. args[1 ], Core, :kwcall ))
286
295
while pc < pccall
287
296
pc = step_expr! (recurse, frame, istoplevel)
288
297
end
289
298
return frame
290
- elseif isexpr (stmt5, :call ) && is_quotenode_egal (stmt5. args[1 ], kwhandler) && pccall+ 1 <= n
299
+ elseif isexpr (stmt5, :call ) && ( is_quotenode_egal (stmt5. args[1 ], kwhandler) || is_global_ref (stmt5 . args[ 1 ], Core, :kwcall ) ) && pccall+ 1 <= n
291
300
# This happens when the call is scoped by a module
292
301
pccall += 1
293
302
while pc < pccall
@@ -298,13 +307,13 @@ function maybe_step_through_kwprep!(@nospecialize(recurse), frame::Frame, istopl
298
307
end
299
308
end
300
309
end
301
- elseif isexpr (stmt, :call ) && is_quoted_type (stmt . args[ 1 ], :NamedTuple ) && length (stmt . args) == 1
310
+ elseif is_empty_namedtuple (stmt)
302
311
# Creating an empty NamedTuple, now split by type (no supplied kwargs vs kwargs...)
303
312
if pc + 1 <= n
304
313
stmt1 = src. code[pc+ 1 ]
305
314
if isexpr (stmt1, :call )
306
315
f = stmt1. args[1 ]
307
- if is_quotenode_egal (f, Base. pairs)
316
+ if is_quotenode_egal (f, Base. pairs) || is_global_ref (f, Base, :pairs )
308
317
# No supplied kwargs
309
318
pcsplat = pc + 3
310
319
if pcsplat <= n
@@ -327,14 +336,14 @@ function maybe_step_through_kwprep!(@nospecialize(recurse), frame::Frame, istopl
327
336
end
328
337
end
329
338
end
330
- elseif is_quotenode_egal (f, Base. merge) && ((pccall = pc + 7 ) <= n)
339
+ elseif ( is_quotenode_egal (f, Base. merge) || is_global_ref (f, Base, :merge )) && ((pccall = pc + 7 + 2 * isbindingresolved_deprecated ) <= n)
331
340
stmtk = src. code[pccall- 1 ]
332
- if isexpr (stmtk, :call ) && is_quotenode_egal (stmtk. args[1 ], kwhandler)
333
- for i = 1 : 4
341
+ if isexpr (stmtk, :call ) && ( is_quotenode_egal (stmtk. args[1 ], kwhandler) || is_global_ref (stmtk . args[ 1 ], Core, :kwcall ) )
342
+ for i = 1 : 4 + isbindingresolved_deprecated
334
343
pc = step_expr! (recurse, frame, istoplevel)
335
344
end
336
345
stmti = src. code[pc]
337
- if isexpr (stmti, :call ) && is_quotenode_egal (stmti. args[1 ], #= deliberately not kwhandler =# Core. kwfunc)
346
+ if isexpr (stmti, :call ) && ( is_quotenode_egal (stmti. args[1 ], #= deliberately not kwhandler =# Core. kwfunc) || is_global_ref (stmti . args[ 1 ], Core, :kwfunc ) )
338
347
pc = step_expr! (recurse, frame, istoplevel)
339
348
end
340
349
end
347
356
maybe_step_through_kwprep! (frame:: Frame , istoplevel:: Bool = false ) =
348
357
maybe_step_through_kwprep! (finish_and_return!, frame, istoplevel)
349
358
359
+ @static if isbindingresolved_deprecated
360
+ function is_empty_namedtuple (stmt)
361
+ isexpr (stmt, :call ) && length (stmt. args) == 1 || return false
362
+ arg1 = stmt. args[1 ]
363
+ isa (arg1, GlobalRef) || return false
364
+ return arg1. name === :NamedTuple
365
+ end
366
+ else
367
+ is_empty_namedtuple (stmt) = isexpr (stmt, :call ) && is_quoted_type (stmt. args[1 ], :NamedTuple ) && length (stmt. args) == 1
368
+ end
369
+
350
370
"""
351
371
ret = maybe_reset_frame!(recurse, frame, pc, rootistoplevel)
352
372
0 commit comments