gleam-lang/gleam

Improve error message for invalid externals

Chiusa

#5561 aperta il 3 apr 2026

 (2 commenti) (0 reazioni) (0 assegnatari)Rust (960 fork)batch import
help wanted

Metriche repository

Star
 (21.417 stelle)
Metriche merge PR
 (Merge medio 10g 19h) (69 PR mergiate in 30 g)

Descrizione

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/

Guida contributor