check array literals against a target Array(T, N) annotation #77
Loading…
Reference in a new issue
No description provided.
Delete branch "us67/check-array-comptime-size-against-annotation"
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 #67.
Threads an
expected: Option<Ty<'db>>hint throughcheck_let→check_expr→check_array_literal, so a bare array literal ([1, 2, 3]) can be checked against a sizedArray(T, N)target instead of always inferringList(T).check_letpasses its annotation's resolved type down asexpected.check_array_literalmatchesexpectedagainstInstantiated { name: Array, args: [Type(_), Value(Literal::Int(_))], .. }and, when it matches, checks element count and element type against it (ArraySizeMismatch/ArrayTypeMismatch), reusing the same instantiation path as the already-written[N]T[...]sized-literal form.expectedshape falls back to the existingList(T)inference unchanged.expectedparam fromcheck_type_expr— it resolves aTypeExpr's syntax into aTyand never had an ambiguity to resolve, unlikecheck_expr.New tests: sized-literal-vs-matching/mismatched annotation, bare-literal-vs-matching/mismatched annotation.
#67's remaining bullet (arbitrary comptime-evaluated sizes, e.g.
Array(Int, computeSize())) is out of scope here — literals-only was already the ceiling set by #66/#71's AST/checker types. Split out to #76.