Check Array(T, N: Comptime(Int)) and Map(K, V) generic instantiation #71
Labels
No labels
bug
design
epic
risk
user-story
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
jacksonopp/twill#71
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Follow-up to #69, split out once #69 was scoped down to just
List(T)for its first pass.#69 resolves a generic container instantiation (
TypeExpr::Generic) to a concreteTyby comptime-evaluating the callee's body under substituted generic-param bindings — but only forList(T), sinceList's definition (struct { items: *T, len: Int }) only needs type-parameter substitution.Array/Mapneed more:Array(T: type, N: Comptime(Int))andMap(K: type, V: type)(persyntax-notes.md) both carry aComptime(_)-kinded param (Array'sN) or otherwise weren't exercised by #69'sList-only pass.Comptime(_)params are compile-time values, not types — nothing inScope/TyKindtoday has a slot for a plain value (onlySymbol -> Ty), so bindingNduring evaluation needs a new mechanism, not just anotherScopeframe entry.Array(Int, 3)andArray(Int, 5)must come out as genuinely differentTys. EvaluatingArray's struct-shaped body under #69's substitution scheme won't naturally distinguish them, since nothing in the resulting fields' types mentionsN(see #67's array-size discussion) — the comptime value has to be carried into the resultingTy's identity some other way.crates/twill-check/src/prelude.tw, added by #69) with realArray/Mapdefinitions and wire them through the same comptime-evaluation pathListuses.This is the issue #67 should point to for its 'blocked on generic-instantiation resolution' dependency, not #69 directly.