You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems to be the calls to getLength and getIx in thawVector (coming from the sugaring of err) that cause the problems. A simpler test case is:
> drawAST $ \a -> a + getLength (err "aaa" :: Data [Index])
*** Exception: Assert failed: aaa
Disabling constant folding removes the problem.
We need to make sure not to constant fold undefined values. Currently, every closed expression with a result type in Type gets constant folded. But I don't think it's enough to turn off constant folding for the constructs in Constructs.Error because
Expressions like
1 + getLength (err "aaa" :: Data [Index])
would still be folded.
We have other sources of undefined values:
> drawAST $ \a -> a + getIx (value [] :: Data [Index]) 1
*** Exception: List.genericIndex: index too large.
I'm not sure exactly why the error gets propagated in these examples, but possible reasons are
Size propagation (sizeOf is strict)
Optimizations matching on specific literals
I think the solution is to lift our semantic domain to e.g. Maybe a. That way, we don't have to use undefined in expressions. This change would probably affect Syntactic (since we don't want the users to see the lifted domain).
Expected result
Due to constant folding?
The text was updated successfully, but these errors were encountered: