Add builtin prelude for List/Array/Map #75

Merged
jacksonopp merged 1 commit from us72/map-list-array-builtins into main 2026-09-24 16:16:17 +00:00
Owner

Closes #72.

fn_decl only ever searched the checked file's own Scope::source, so using List/Array/Map required redeclaring them in every file - no way to use the container-literal sugar without that boilerplate.

  • Adds crates/twill-check/prelude/prelude.tw, a real .tw source with the List/Array/Map declarations, include_str!'d in.
  • prelude_source (queries.rs): a zero-argument #[salsa::tracked] query so the same SourceFile (and its memoized lower/fn_decl results) is reused across calls in a revision.
  • resolve_fn_decl (ty.rs): tries scope.source first, falls back to prelude_source(db). evaluate_generic_call's single fn_decl call site now goes through this instead.
  • Updated 3 check_map_literal tests that previously asserted None for an undeclared Map - now correctly resolve via the prelude.
Closes #72. `fn_decl` only ever searched the checked file's own `Scope::source`, so using `List`/`Array`/`Map` required redeclaring them in every file - no way to use the container-literal sugar without that boilerplate. - Adds `crates/twill-check/prelude/prelude.tw`, a real `.tw` source with the `List`/`Array`/`Map` declarations, `include_str!`'d in. - `prelude_source` (`queries.rs`): a zero-argument `#[salsa::tracked]` query so the same `SourceFile` (and its memoized `lower`/`fn_decl` results) is reused across calls in a revision. - `resolve_fn_decl` (`ty.rs`): tries `scope.source` first, falls back to `prelude_source(db)`. `evaluate_generic_call`'s single `fn_decl` call site now goes through this instead. - Updated 3 `check_map_literal` tests that previously asserted `None` for an undeclared `Map` - now correctly resolve via the prelude.
add builtin prelude for List/Array/Map
All checks were successful
CI / check (pull_request) Successful in 3m33s
ae2724ce72
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jacksonopp/twill!75
No description provided.