Skip to content

Suggest fun when fn is used at the top level #359

Closed

Description

@LunaStev

Tracked by #346.

Problem

Wave uses fun for function declarations. A source file beginning with fn main() {} currently reports only an unexpected top-level identifier and lists every valid declaration kind.

Expected diagnostic

The error should point at fn and include a direct suggestion such as:

did you mean `fun`?

The compiler must not silently rewrite the source.

Scope

  • Detect the exact identifier fn where a top-level declaration is expected.
  • Preserve the normal unexpected-token diagnostic for other identifiers.
  • Provide the same message and span in human and JSON error formats.
  • Add a regression for fn main() {} and a control case for an unrelated identifier.

Completion criteria

  • The primary span points to fn.
  • Help mentions fun.
  • Exit status remains a syntax-error failure.
  • No new keyword or alias is added to Wave.

Activity

  1. added
    enhancement
    good first issue
    on Aug 25, 2026
  2. added a commit that references this issue on Oct 22, 2026
    aef39a5
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

    enhancementgood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions