Repository navigation
Tighten lambda parameter syntax check - #166
Conversation
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
|
||
| Parameter type annotations must be given for every parameter or omitted for every | ||
| parameter. Partially annotated forms such as `(x: Int, y) => x + y` and | ||
| `(x, y: Int) => x + y` are rejected, even when an expected function type is available. |
There was a problem hiding this comment.
can we actually accept (x, y: Int) as equal to (x: Int, y: Int)? it would be more concise if the function has multiple parameters of the same type
There was a problem hiding this comment.
That is possible, but it would break integrity: in many languages (x, y: Int) mean that both x and y have the type Int.
From evolution perspective, we should be more strict in the beginning.
Tighten lambda parameter syntax check
Summary
The parameters of lambda should either have no type annotations, or all have type annotations. Previously, the check was missing and the spec is not clear about the detail.
Checklist
tests/pos/ortests/warn/A JIP is required for language changeThis is really a missing check, not a language change, thus a JIP is not needed.
How to sign off commits
Use
git commit -sto add theSigned-off-byline automatically:To add a sign-off to the last commit retroactively:
To add sign-off to the last 3 commits:
Security impact
No
Compatibility impact
This will affect existing code if they abuse the missing check. No code in internal libraries nor this repo use this syntax.