resolve List(T) generic-call instantiation #73
Loading…
Reference in a new issue
No description provided.
Delete branch "us69/list-generic-instantiation"
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 #69.
Comptime-evaluates a generic type-function call (
List(Int)-shaped) into a realTy, rather than leavingTypeExpr::Genericpermanently unresolved. A newfn_declsalsa query looks up a callee's declaration by name within a givenSourceFile;evaluate_generic_callbinds eachT: typeparam to its resolved argument in a fresh scope frame and checks the body under that substitution — reusingcheck_struct/check_exprrather than adding dedicated containerTyKindvariants, soList(Int)/List(Bool)fall out as genuinely different, correctly-shapedStructtypes for free.Also landed as prerequisites/along the way:
TypeExpr::Pointer-> newTyKind::Pointer), needed sinceList's own body (items: *T) uses one.-> type-declared function's return type is now satisfied by any concreteTyits body produces, rather than requiring exact equality with the abstractTypemarker (check_fn's return-type check) — needed forListitself to type-check as a declaration at all.name_hintnow threads throughBlock/Fnbodies so a function whose body is{ struct { ... } }gets its struct correctly named, instead of hittingNamelessStruct.check_array_literal/check_map_literal's bare and typed cases now resolve to realList(T)/Map(K, V)shapes instead of their old placeholder result types.Split off along the way, not included here:
Array'sComptime(Int)size and generalComptime(_)-value-param support (Map's params are both plaintype-kinded, so it needed noComptimesupport and already works here).List/Array/Mapdon't need declaring inline in every checked file (every test here declares them inline, sincefn_declonly searches the given file).Test plan
[x] cargo test -p twill-check (215 passing)
[x] cargo clippy --workspace --tests (clean)