tidy what the fixes wrote around existing helpers
All checks were successful
Sex CI / build-linux (pull_request) Successful in 5m55s
Sex CI / build-linux (push) Successful in 5m57s

written-type? matches the shapes instead of measuring them, array-form?
and pub-form? replace their spelled-out copies, both test files share
one fails-with?, and moved test comments are back above their groups.
This commit was merged in pull request #66.
This commit is contained in:
2026-10-19 18:21:14 +03:00
parent a4880f1b96
commit 540f5c75cd
5 changed files with 23 additions and 27 deletions

View File

@@ -795,14 +795,12 @@
;;; (* char) (* const char) (* size-t) (unsigned int) types
;;; (* p) (* (g)) (¤ xs 0) expressions
(define (written-type? form env)
(and (pair? form)
;; the length a dereference and a subscript have
(if (= (length form) (case (car form) ((*) 2) ((¤) 3) (else -1)))
(let ((operand (second form)))
(if (symbol? operand)
(not (or (lookup-name env operand) (get-name-type operand)))
(written-type? operand env)))
(type-head? form))))
(match form
((or ('* operand) ('¤ operand _))
(if (symbol? operand)
(not (or (lookup-name env operand) (get-name-type operand)))
(written-type? operand env)))
(_ (type-head? form))))
;;; `(var n _ (strlen s))' becomes `(var n size-t (strlen s))'.
(define (resolve-wildcard form env)
@@ -1143,7 +1141,7 @@
;;; A field of a path, indexed or not: xs, [xs 0] -> xs
(define (field-name field)
(if (and (pair? field) (eq? '¤ (car field)) (pair? (cdr field)))
(if (and (array-form? field) (pair? (cdr field)))
(second field)
field))