google-research / dex-lang

Research language for array processing in the Haskell/ML family
BSD 3-Clause "New" or "Revised" License
1.58k stars 107 forks source link

Can't handle toplevel case with a functional value? #1217

Closed axch closed 1 year ago

axch commented 1 year ago
@noinline
def id' (x:Bool) : Bool = x

case (id' True) of
  True -> Just f64_to_f
  False -> Nothing
> Compiler bug!
> Please report this at github.com/google-research/dex-lang/issues
>
> Not a data atom: (acase (ProjectElt 1 v#1) [(\v#4:Unit.(0| () |)), (\v#4:Unit.(1| f64_to_ |))])
> CallStack (from HasCallStack):
>   error, called at src/lib/Simplify.hs:184:14 in dex-0.1.0.0-Gi9B8TxRbicLQnuTnmjlXJ:Simplify

Expected

> (Just <function of type (Float64 -> Float32)>)

(The id' is needed to defeat case-of-known-constructor optimization, which masks the bug).

axch commented 1 year ago

(The same thing seems to happen when attempting to implement catch do f64_to_f, which is the last item left from #1193.)