Skip to content
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

Unexpected undefined #24

Closed
emilaxelsson opened this issue Oct 30, 2012 · 1 comment
Closed

Unexpected undefined #24

emilaxelsson opened this issue Oct 30, 2012 · 1 comment
Labels

Comments

@emilaxelsson
Copy link
Member

> eval $ case Indexed 0 (\i -> err "sdf") Empty :: Matrix Index of Indexed l ixf Empty -> (ixf 0) 
*** Exception: Prelude.undefined

Expected result

*** Exception: sdf

Due to constant folding?

@emilaxelsson
Copy link
Member Author

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).

emilaxelsson added a commit that referenced this issue Dec 3, 2014
This is because recurrenceI uses an empty output buffer, which triggers #24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant