-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Fix broadcast error when eltype is inconsistent with getindex #39185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
In that case we can infer the return type as `Union{}`, which triggers a type assertion error. This used to work in Julia 1.5.
Wait, so the compiler infers |
Oooh, I see. It's because we use (and trust) eltype when guessing the return type, but don't actually do that when evaluating the expression. Further, we don't call |
Maybe we should just ask inference for the |
Co-authored-by: Simeon Schaub <simeondavidschaub99@gmail.com>
Indeed. In general, assuming that Though I think it would be safer not to make that change in 1.6, so better backport this one, and only merge #39295 to master? |
Co-authored-by: Matt Bauman <mbauman@juliacomputing.com>
@mbauman @KristofferC Should we merge and backport this? #39295 seems to be harder to implement, and too disruptive for 1.6 anyway. |
Yes, this seems reasonable to me — especially as a patch for 1.6's behavior. |
* Fix broadcast error when eltype is inconsistent with getindex In that case we can infer the return type as `Union{}`, which triggers a type assertion error. This used to work in Julia 1.5. * whitespace Co-authored-by: Simeon Schaub <simeondavidschaub99@gmail.com> * Update test/broadcast.jl Co-authored-by: Matt Bauman <mbauman@juliacomputing.com> Co-authored-by: Matt Bauman <mbauman@juliacomputing.com> Co-authored-by: Simeon Schaub <simeondavidschaub99@gmail.com> (cherry picked from commit 750f42a)
* Fix broadcast error when eltype is inconsistent with getindex In that case we can infer the return type as `Union{}`, which triggers a type assertion error. This used to work in Julia 1.5. * whitespace Co-authored-by: Simeon Schaub <simeondavidschaub99@gmail.com> * Update test/broadcast.jl Co-authored-by: Matt Bauman <mbauman@juliacomputing.com> Co-authored-by: Matt Bauman <mbauman@juliacomputing.com> Co-authored-by: Simeon Schaub <simeondavidschaub99@gmail.com> (cherry picked from commit 750f42a)
…ang#39185) * Fix broadcast error when eltype is inconsistent with getindex In that case we can infer the return type as `Union{}`, which triggers a type assertion error. This used to work in Julia 1.5. * whitespace Co-authored-by: Simeon Schaub <simeondavidschaub99@gmail.com> * Update test/broadcast.jl Co-authored-by: Matt Bauman <mbauman@juliacomputing.com> Co-authored-by: Matt Bauman <mbauman@juliacomputing.com> Co-authored-by: Simeon Schaub <simeondavidschaub99@gmail.com>
…ang#39185) * Fix broadcast error when eltype is inconsistent with getindex In that case we can infer the return type as `Union{}`, which triggers a type assertion error. This used to work in Julia 1.5. * whitespace Co-authored-by: Simeon Schaub <simeondavidschaub99@gmail.com> * Update test/broadcast.jl Co-authored-by: Matt Bauman <mbauman@juliacomputing.com> Co-authored-by: Matt Bauman <mbauman@juliacomputing.com> Co-authored-by: Simeon Schaub <simeondavidschaub99@gmail.com>
* Fix broadcast error when eltype is inconsistent with getindex In that case we can infer the return type as `Union{}`, which triggers a type assertion error. This used to work in Julia 1.5. * whitespace Co-authored-by: Simeon Schaub <simeondavidschaub99@gmail.com> * Update test/broadcast.jl Co-authored-by: Matt Bauman <mbauman@juliacomputing.com> Co-authored-by: Matt Bauman <mbauman@juliacomputing.com> Co-authored-by: Simeon Schaub <simeondavidschaub99@gmail.com> (cherry picked from commit 750f42a)
In that case we can infer the return type as
Union{}
, which triggers a type assertion error. This used to work in Julia 1.5. (I'm not sure this kind of thing is legitimate but this is probably not the best place to throw an error about it anyway.)Fixes #38422.