Skip to content

Miscompilation of invalid conditionals when both branches yield the same value #29306

@getzze

Description

@getzze
julia> VERSION
v"1.0.0"

julia> a = [1,2,3,4,missing,6,7]
7-element Array{Union{Missing, Int64},1}:
 1       
 2       
 3       
 4       
  missing
 6       
 7       

julia> y = 6; b = [ (x>y ? missing : x)  for x in a]
ERROR: TypeError: non-boolean (Missing) used in boolean context

julia> c = [ (x>6 ? -1 : x)  for x in a]
ERROR: TypeError: non-boolean (Missing) used in boolean context

julia> d = [ (x>6 ? missing : -1)  for x in a]
ERROR: TypeError: non-boolean (Missing) used in boolean context

julia> e = [ (x>6 ? missing : x)  for x in a]
7-element Array{Union{Missing, Int64},1}:
 1       
 2       
 3       
 4       
  missing
 6       
  missing

The definition of e should give the same error as for c and d, or at least b!

Metadata

Metadata

Assignees

Labels

compiler:optimizerOptimization passes (mostly in base/compiler/ssair/)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions