Skip to content

Language decision: expression-bodied fn / getter does not return its value #60

Closed

Description

@otnc

fn double x to x mul 2 compiles to function double(x) { x * 2; } (no return), and get fn value to this.count to get value() { this.#count; }. The examples document this as "expression body (no return)" and require to return expr.

This is surprising for users coming from arrow-function style (x => x * 2) and silently produces undefined. The compiler could warn today.

Options

  1. Keep the semantics, add a diagnostic/linter rule: "expression body has no effect, did you mean to return?" (non-breaking).
  2. Make to expr return the expression (breaking change for code that relies on the statement form; needs a major version or an opt-in flag).
  3. Introduce a distinct arrow-style form and leave to unchanged.

Needs a maintainer decision; option 1 can ship regardless.

Activity

  1. otnc commented on Oct 16, 2026

    @otnc
    MemberAuthor

    Decision (#91): keep the semantics (changing them is breaking, major only). The linter warns on named fn / getter expression bodies without return (rule expression-body-no-return) and the RFC documents it. Anonymous 'fn x to expr' already returns.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions