Context
Identified during spec-test alignment audit (DIV-5). The lambda type annotation syntax creates a parsing ambiguity with the double-colon problem.
Current behavior
Lambda expressions use the syntax lambda x: x + 1. If we want to add type annotations to lambda parameters (like lambda x: int: x + 1), the parser cannot distinguish between the type annotation colon and the body-start colon.
Expected/proposed
An RFC is needed to decide on a syntax for lambda type annotations that avoids the double-colon ambiguity. Possible approaches:
lambda (x: int): x + 1 — parenthesized parameters
lambda x as int: x + 1 — alternative annotation syntax
- Require full
def for typed lambdas — simplest but most restrictive
- Reference the property syntax decision for consistency
This is a language design question that needs community input before implementation.
References
docs/language_specification/expressions.md — lambda expression syntax
docs/language_specification/type_system.md — type annotations
Context
Identified during spec-test alignment audit (DIV-5). The lambda type annotation syntax creates a parsing ambiguity with the double-colon problem.
Current behavior
Lambda expressions use the syntax
lambda x: x + 1. If we want to add type annotations to lambda parameters (likelambda x: int: x + 1), the parser cannot distinguish between the type annotation colon and the body-start colon.Expected/proposed
An RFC is needed to decide on a syntax for lambda type annotations that avoids the double-colon ambiguity. Possible approaches:
lambda (x: int): x + 1— parenthesized parameterslambda x as int: x + 1— alternative annotation syntaxdeffor typed lambdas — simplest but most restrictiveThis is a language design question that needs community input before implementation.
References
docs/language_specification/expressions.md— lambda expression syntaxdocs/language_specification/type_system.md— type annotations