gleam-lang/gleam

Improve error message for invalid externals

Open

#5561 opened on Apr 3, 2026

View on GitHub
 (2 comments) (0 reactions) (0 assignees)Rust (21,417 stars) (960 forks)batch import
help wanted

Description

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/

Contributor guide