-
Notifications
You must be signed in to change notification settings - Fork 6
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
Allow defaults in function signatures with syntax (..., p = e, ...). #30
base: master
Are you sure you want to change the base?
Conversation
There is a potential issue when the other parameters are bound to the default expression:
This code causes the scoping to break, which can be observed by a number of free parameters being found during thorin's internal verification. |
Revert adding DefaultParamType. Instead, use CallExpr::infer. This only works if the parameter and argument lists materialize as tuples. Single parameters are not encapsulated like that and need special treatment later down the line.
I changed the way defaults are propagated somewhat. The following example should work:
Lines 1190 to 1191 in ed0d2d8
I don't know of any good ways to copy an ast::Node the way it would be required here. The way this is currently implemented generated multiple unique pointers to the same address, leading to undefined behavior. |
This syntax is used elsewhere as well, but very inconsistently. An alternative, at least on Linux/Mac, is to output to /dev/stdout instead.
This hijacks the implicit summoning to also allow for defaults to be specified. Type checking infers a type for the supplied expression first, and then checks that the parameter matches. As a consequence, the following variants are all valid: