Render param-not-in-restricted-set allowed set in AILang syntax, not Rust debug #52

Closed
opened 2026-05-30 18:23:40 +02:00 by Brummel · 0 comments
Owner

Summary

The param-not-in-restricted-set diagnostic renders the allowed element set as a Rust debug list rather than AILang type syntax. An author reading the message sees Rust formatting leaking into a language-level diagnostic.

Reproduction (verified, current HEAD)

A RawBuf with a forbidden element type in a fn signature position:

(fn make (type (fn-type (params (con Int)) (ret (own (con RawBuf (con Unit)))))) (params n)
  (body (new RawBuf (con Unit) n)))

ail check ->

[param-not-in-restricted-set] make: type-arg `Unit` is not in the restricted set for type-variable `a` of `raw_buf.RawBuf` (allowed: one of ["Bool", "Float", "Int"])

The set renders as ["Bool", "Float", "Int"] — a {:?} debug print of a sorted Rust collection (note the quotes, brackets, and alphabetical order). The author-facing form would be AILang type names, e.g. {Int, Float, Bool} or Int | Float | Bool.

Where

The message was added in the B3 fix (issue #48) on CheckError::ParamNotInRestrictedSet (crates/ailang-check/src/lib.rs, the #[error] attribute, ~line 749). The (allowed: one of {allowed:?}) interpolation uses the debug formatter on the allowed-set collection.

Impact

Cosmetic / diagnostic quality. The diagnostic is correct and fires at the right place; only the rendering of the set is Rust-shaped rather than AILang-shaped. AILang's audience is an LLM author, so diagnostic surface that reads as the target language matters.

Acceptance

  • The allowed set renders in AILang type syntax (no Rust quotes/brackets), in a stable order
## Summary The `param-not-in-restricted-set` diagnostic renders the allowed element set as a Rust debug list rather than AILang type syntax. An author reading the message sees Rust formatting leaking into a language-level diagnostic. ## Reproduction (verified, current HEAD) A `RawBuf` with a forbidden element type in a fn signature position: ``` (fn make (type (fn-type (params (con Int)) (ret (own (con RawBuf (con Unit)))))) (params n) (body (new RawBuf (con Unit) n))) ``` `ail check` -> ``` [param-not-in-restricted-set] make: type-arg `Unit` is not in the restricted set for type-variable `a` of `raw_buf.RawBuf` (allowed: one of ["Bool", "Float", "Int"]) ``` The set renders as `["Bool", "Float", "Int"]` — a `{:?}` debug print of a sorted Rust collection (note the quotes, brackets, and alphabetical order). The author-facing form would be AILang type names, e.g. `{Int, Float, Bool}` or `Int | Float | Bool`. ## Where The message was added in the B3 fix (issue #48) on `CheckError::ParamNotInRestrictedSet` (`crates/ailang-check/src/lib.rs`, the `#[error]` attribute, ~line 749). The `(allowed: one of {allowed:?})` interpolation uses the debug formatter on the allowed-set collection. ## Impact Cosmetic / diagnostic quality. The diagnostic is correct and fires at the right place; only the rendering of the set is Rust-shaped rather than AILang-shaped. AILang's audience is an LLM author, so diagnostic surface that reads as the target language matters. ## Acceptance - [ ] The allowed set renders in AILang type syntax (no Rust quotes/brackets), in a stable order
Brummel added the bug label 2026-05-30 18:23:40 +02:00
Sign in to join this conversation.