Generics: check T: type params and List(T)-shaped calls #53
Loading…
Reference in a new issue
No description provided.
Delete branch "us6/type-params-and-list-t"
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?
Closes #6.
Summary
T: typeparams: two newTyKindvariants —Type(no payload, resolved from the literal name"type") andTypeParam(Symbol)(nominal, one per type-parameter name, same "carries a name" reasoning asTyKind::Struct/TyKind::Enum).check_fn's per-param loop binds aT: typeparam's name toTypeParam(T)(notTypeitself) so later params/return type (x: T,-> T) can reference it.resolve_type_exprgains a&Scopeparameter so bound type params are actually findable, falling back toscope.lookupfor any name that isn't a hardcoded primitive.List(T)-shaped calls: ride oncheck_call(built in #3) for free once a function's own signature resolves correctly — the missing piece was that primitive names (Int,Float, ...) used as ordinary value expressions (e.g.List(Int)'s argument) didn't resolve to anything, since primitive recognition only existed in type-annotation position.check_identnow recognizes them too, always resolving toTy::type_(db)(the kind) regardless of which specific primitive — nested calls (List(List(Int))) compose with no special-casing.primitive_tyextracted as a shared helper betweenresolve_type_exprandcheck_ident— but not reused verbatim, since the two call sites are answering different questions (annotation-position "what type does this name denote" vs. value-position "what is the type of this value"). A first draft conflated the two and returned the wrongTyfromcheck_ident; caught by the test suite, documented indocs/type-checker-design.mdso it doesn't recur.docs/type-checker-design.mdgets a new## Issue #6section covering all of the above, plus an explicit "Out of scope" list: struct/enum names as generic arguments (List(Vec3)—Vec3's scope binding can't currently answer both "what is Vec3's definition" and "what is the type of the value Vec3," a real design question bigger than this issue), andTypeExpr::Generic(the type-annotation-position form, e.g.let x: List(Int)— structurally separate from theExpr::Callvalue-position form this issue covers).Test plan
cargo test --workspacecargo fmt --all -- --checkcargo clippy --workspace --all-targets --all-features -- -D warnings19ad125f8d93db08bfff93db08bfffedf59b96fd