wavefnd / wavefnd/Wave

Suggest fun when fn is used at the top level

Open
#359 0 comments 0 reactions 0 assignees View on GitHub
enhancement good first issue
Dominant language
Rust
Stars
53
Forks
16
Avg merge
4h 22m
Merged PRs (30d)
46

Description

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:

```text
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.

Contributor guide

Open the contributing guide

Research direction

Locate the compiler code that handles top-level declaration expectations and the existing human and JSON diagnostic tests. Add regression coverage for `fn main() {}` plus an unrelated identifier control case, then verify the `fn` span, `fun` help text, unchanged syntax-error exit status, and matching messages across both formats.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
75/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.