Skip to content

Tighten lambda parameter syntax check - #166

Merged
liufengyun merged 3 commits into
mainfrom
tighten-lambda
Oct 18, 2026
Merged

liufengyun merged 3 commits into
mainfrom
tighten-lambda

Conversation

@liufengyun

Copy link
Copy Markdown
Member

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

  • Added / updated tests under tests/pos/ or tests/warn/
  • Docs updated if the change affects user-visible behavior
  • A JIP is required for language change
  • All commits are signed off (why?)

This is really a missing check, not a language change, thus a JIP is not needed.

How to sign off commits

Use git commit -s to add the Signed-off-by line automatically:

To add a sign-off to the last commit retroactively:

git commit --amend -s --no-edit

To add sign-off to the last 3 commits:

git rebase --signoff HEAD~3

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.

  • Source compatibility
    • syntax parsing
    • type checking
  • SAST compatibility
    • forward compatibility: new libraries can be used by old compiler
    • backward comopatibility: old libraries can be used by new compiler
  • Standard Library compatibility:
    • forward compatibility: new code can work with old stdlib
    • backward compatibility: old code work with the new stdlib
  • Runtime Library compatibility:
    • forward compatibility: new code can work with old runtime
    • backward compatibility: old code work with the new runtime
  • Build tool
    • Build spec compatibility: old projects continue to build
    • Joy package compatibility: old .joy can be consumed by new build tool

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>
@liufengyun
liufengyun requested review from everdance and a balanced review from Copilot October 17, 2026 20:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@liufengyun
liufengyun added this pull request to stack #168 October 17, 2026 22:40

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.

@everdance everdance Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@liufengyun
liufengyun merged commit 186bf96 into main Oct 18, 2026
3 checks passed
@liufengyun
liufengyun deleted the tighten-lambda branch October 18, 2026 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants