Skip to content

mojo-syntax: "No lambda" is incorrect — lambda works in 1.1.0 and is used by the official tutorial #12

Description

@ponkster

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions