Skip to content

Commit 55d5921

Browse files
committed
fix thrown exception when reaching depth limit
1 parent 1cb1cb6 commit 55d5921

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

base/promotion.jl

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ function _promote_type_binary_detect_loop(T::Type, S::Type, A::Type, B::Type)
402402
onesided(T, S, A, B) || onesided(T, S, B, A)
403403
end
404404

405-
macro _promote_type_binary_step()
405+
macro _promote_type_binary_step1()
406406
e = quote
407407
# Try promote_rule in both orders.
408408
ts = promote_rule(T, S)
@@ -425,12 +425,26 @@ macro _promote_type_binary_step()
425425
# makes for nicer UX.
426426
_promote_type_binary_err_detected_infinite_recursion(T_initial, S_initial, T, S, ts, st)
427427
end
428+
end
429+
esc(e)
430+
end
431+
432+
macro _promote_type_binary_step2()
433+
e = quote
428434
T = ts
429435
S = st
430436
end
431437
esc(e)
432438
end
433439

440+
macro _promote_type_binary_step()
441+
e = quote
442+
@_promote_type_binary_step1
443+
@_promote_type_binary_step2
444+
end
445+
esc(e)
446+
end
447+
434448
function _promote_type_binary(T::Type, S::Type)
435449
T_initial = T
436450
S_initial = S
@@ -442,7 +456,8 @@ function _promote_type_binary(T::Type, S::Type)
442456
@_promote_type_binary_step
443457
@_promote_type_binary_step
444458
@_promote_type_binary_step
445-
@_promote_type_binary_step
459+
460+
@_promote_type_binary_step1
446461

447462
_promote_type_binary_err_giving_up(T_initial, S_initial, T, S, ts, st)
448463
end

0 commit comments

Comments
 (0)