-
Notifications
You must be signed in to change notification settings - Fork 28
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
Optional args #183
base: new-definition-typing
Are you sure you want to change the base?
Optional args #183
Conversation
It seems that the branch you merged earlier was still a wildly outdated version. That's why it would help you to use a git GUI, which would allow you to better visualize what you're doing. |
I will give it a try! |
You messed up the merge a bit. File QML_exist_Classes_CT.mls was deleted from the main branch and you mistakenly reinstated it. |
Test cases to addAs discussed on Discord, here are expected usages of optional parameters: fun foo0(x: Int?) = if x is undefined then 0 else x + 1
fun foo1(x?) = if x is undefined then 0 else x + 1 The following should not type check :e
fun foo0(x: Int?) = x + 1
:e
fun foo1(x?) = x + 1 To do this, you have to adapt the typing of tuples when in pattern positions. And some interesting cases to add, which contain signature checks: fun foo: (x: Int?) -> Int
fun foo(x?) = if x is undefined then 0 else x + 1
// Ok: function with optional parameter can be widened to function with mandatory parameter
fun foo: (x: Int) -> Int
fun foo(x?) = if x is undefined then 0 else x + 1
:e // The definition's parameter spec is too strong
fun foo: (x: Int?) -> Int
fun foo(x) = x + 1 And some subtype tests:
I expect we could accept the case above by constraining |
No description provided.