gleam-lang/gleam

Improve error message for invalid externals

已关闭

#5,561 创建于 2026年4月3日

 (2 条评论) (0 个反应) (0 位负责人)Rust (960 个派生)batch import
help wanted

仓库指标

星标
 (21,417 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

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/

贡献者指南