-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
type constraints from multiple ||
conditions don't propagate well
#39611
Labels
compiler:inference
Type inference
Comments
simeonschaub
added a commit
that referenced
this issue
Feb 11, 2021
What this PR does is expand for example ```julia if x === nothing || x < 0 return 0 end ``` to ```julia if x === nothing @goto l else if x < 0 @Label l 0 end end ``` in lowering, which IIUC correctly should correspond to the first option @vtjnash proposed in https://github.com/JuliaLang/julia/pull/39549/files#r573995564. Are there any potential problems with emitting `goto`s here? Or is there a nicer way to fix this than in `expand-if`? fixes #39611
simeonschaub
added a commit
that referenced
this issue
Feb 11, 2021
What this PR does is expand for example ```julia if x === nothing || x < 0 return 0 end ``` to ```julia if x === nothing @goto l else if x < 0 @Label l 0 end end ``` in lowering, which IIUC should correspond to the first option @vtjnash proposed in https://github.com/JuliaLang/julia/pull/39549/files#r573995564. Are there any potential problems with emitting `goto`s here? Or is there a nicer way to fix this than in `expand-if`? fixes #39611
JeffBezanson
pushed a commit
that referenced
this issue
Feb 12, 2021
We still might want to do the inference improvement too, since that should handle the case where the user wrote it out rather verbosely (like below). It might however be odd that julia> function f(x)
x = x[]
y = x === nothing
if y
z = y
else
z = x < 0
end
if z
return 0
end
return x
end |
aviatesk
added a commit
to aviatesk/julia
that referenced
this issue
Feb 13, 2021
aviatesk
added a commit
to aviatesk/julia
that referenced
this issue
Feb 15, 2021
aviatesk
added a commit
to aviatesk/julia
that referenced
this issue
Feb 16, 2021
ElOceanografo
pushed a commit
to ElOceanografo/julia
that referenced
this issue
May 4, 2021
antoine-levitt
pushed a commit
to antoine-levitt/julia
that referenced
this issue
May 9, 2021
KristofferC
pushed a commit
that referenced
this issue
Jul 12, 2021
KristofferC
pushed a commit
that referenced
this issue
Aug 31, 2021
staticfloat
pushed a commit
that referenced
this issue
Dec 23, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Originally posted at https://github.com/JuliaLang/julia/pull/39549/files#r571434978
Constraints don't propagate well in the following case:
Ideas to fix are quoted from @vtjnash 's response:
The text was updated successfully, but these errors were encountered: