Navigation Menu

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

Object and function contracts conflicts when used in OR #36

Open
TobiaszCudnik opened this issue Mar 11, 2012 · 2 comments
Open

Object and function contracts conflicts when used in OR #36

TobiaszCudnik opened this issue Mar 11, 2012 · 2 comments
Labels

Comments

@TobiaszCudnik
Copy link

Object and function contracts conflicts when used in OR. Both tests should pass.

TFunc = ? (Any?)  -> Any?

TSignalData = ? TFunc or {
    foo: Any
    bar: Any
}

a :: (TSignalData) -> Any
a = (b) ->

# test
a ->
a foo: 1, bar: 2
@disnet
Copy link
Owner

disnet commented Apr 19, 2012

So there are actually two problems here :)

First, the or in TSignalData is being treated as a normal logical or (ie ||) instead of the contract combinator or. This is basically the same bug as in #38.

But, even if there wasn't a bug this still isn't a valid contract. The problem is you can't have two "higher-order" contracts in an or. Since both the function and the object have delayed behavior, there's no way to check them both. So we have to disallow more than one higher-order contract in an or combinator.

So when the #38 bug is fixed you'll get an error message saying "Error: Cannot have more than 1 higher order contract in 'or'" which is correct.

@disnet
Copy link
Owner

disnet commented Apr 19, 2012

Wait...what I said was wrong. Turns out we actually can and should allow a function and an object in an or combinator. Easy to distinguish the cases by typeof. Where it falls apart is multiple higher-order functions which we still can't allow.

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

2 participants