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

Conditionals in default bodies #91

Open
pbroadbery opened this issue Nov 4, 2013 · 0 comments
Open

Conditionals in default bodies #91

pbroadbery opened this issue Nov 4, 2013 · 0 comments

Comments

@pbroadbery
Copy link
Member

The code below compiles, but produces incorrect results --- 'hash' is referred to, but not given a value (it should come from %, in the same way as q). The problem is due to the conditional test '% has BasicType' not being noted correctly by the with body.

The function zz shows the same behaviour, but is less tractable, as the 'first' function depends on the value of T.

Trivial workaround for the first problem is to uncomment the commented line.

#include "foamlib"

I ==> SingleInteger;

Foo: Category == with {
    f: % -> I;
    q: % -> I;

    default {
        basic? ==> % has BasicType;
    f(n: %): I == {
       basic? => hash n;
       q n;
    }
--  if % has BasicType then { qq(a: %): I == never }
    zz(T: BasicType, x: %): T == if % has ListCategory T then first x else never;
    }
}
pbroadbery added a commit that referenced this issue Nov 10, 2013
…nce to

'% has CopyableType' at the top level of the default body.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant