mojo-syntax/SKILL.md line 623, under Function types and closures, states:
No lambda. Closures use bare def with a capture list in {} after the arg list.
lambda compiles cleanly on Mojo 1.1.0 (8189361e), including with --Werror, with no deprecation warning:
struct Grid[num_cols: Int]:
comptime to_index = lambda (x: Int, y: Int) -> Int: y * Self.num_cols + x
def main() raises:
print(Grid[8].to_index(3, 2)) # prints 19
It also captures locals, so the claim doesn't hold within the closures context either:
def main() raises:
var n = 10
var f = lambda (x: Int) -> Int: x + n
print(f(5)) # prints 15
Why this matters
The skill opens with "Always follow this skill over pretrained knowledge", and Modular's own get-started tutorial uses lambda in 7 places — including the Grid struct's to_index / to_coord:
comptime to_index = lambda (x: Int, y: Int) -> Int: (
y * Self.num_cols + x
)
So an agent following the skill will reject or rewrite the tutorial's own code. I hit exactly this while working through the tutorial: I second-guessed it, rewrote the working lambda code, and only later found the skill was wrong.
Suggested fix
Replace "No lambda." with what's actually intended. If unified closures are preferred stylistically, say that — e.g. "Prefer unified closures over lambda for anything beyond a single expression" — rather than asserting the syntax doesn't exist.
Environment
- Mojo 1.1.0 (8189361e), installed via
pixi add mojo
- Linux x86-64, glibc 2.44
mojo-syntax/SKILL.mdline 623, under Function types and closures, states:lambdacompiles cleanly on Mojo 1.1.0 (8189361e), including with--Werror, with no deprecation warning:It also captures locals, so the claim doesn't hold within the closures context either:
Why this matters
The skill opens with "Always follow this skill over pretrained knowledge", and Modular's own get-started tutorial uses
lambdain 7 places — including theGridstruct'sto_index/to_coord:So an agent following the skill will reject or rewrite the tutorial's own code. I hit exactly this while working through the tutorial: I second-guessed it, rewrote the working
lambdacode, and only later found the skill was wrong.Suggested fix
Replace "No lambda." with what's actually intended. If unified closures are preferred stylistically, say that — e.g. "Prefer unified closures over
lambdafor anything beyond a single expression" — rather than asserting the syntax doesn't exist.Environment
pixi add mojo