Skip to content

Improve error message for invalid externals #5561

@ankddev

Description

@ankddev

Similar to #5557.

Assume following code:

@external
pub fn wibble()

The build tool gives this vague message:

error: Syntax error
  ┌─ C:\Users\user\projects\test_gleam\src\test_gleam.gleam:2:1
  │
2 │ pub fn wibble()
  │ ^^^ I was not expecting this

Found the keyword `pub`, expected one of:
- `(`

It could be improved like:

error: Syntax error
  ┌─ C:\Users\user\projects\test_gleam\src\test_gleam.gleam:1:1
  │
1 │ @external
  │ ^^^^^^^^^ This attribute is incomplete

Found the keyword `pub`, expected one of:
- `(`
Hint: See https://tour.gleam.run/advanced-features/externals/

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedContributions encouraged

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions