My hypothesis is that the inference failure ultimately traces back to problem with the unreliable approximation of `Core.Compiler.return_type` · Issue #35800 · JuliaLang/julia · GitHub. There are several other github issues that are ultimately examples of this, most of them encoutering the issue due to broadcasting. Examples:
- Function redefinition can improve performance/inlining/inference · Issue #32552 · JuliaLang/julia · GitHub
- Mysterious inference failure that can be solved by redefining function · Issue #35537 · JuliaLang/julia · GitHub
- Typeinference depends on execution order but should not · Issue #45388 · JuliaLang/julia · GitHub
- @code_warntype shows the following code is type unstable · Issue #49970 · JuliaLang/julia · GitHub
- maybe Non-deterministic inference results? · Issue #50735 · JuliaLang/julia · GitHub