walk what an initializer holds

The body walk passed a #(...) by as an atom, so nothing inside one was
typed, dispatched or lifted: (. self p) read as self.p with self a
pointer, where the same path outside the literal was right.

Fixes #45.
This commit is contained in:
2026-10-09 17:27:02 +03:00
parent baf2f92fce
commit b73cf36160
3 changed files with 32 additions and 1 deletions

View File

@@ -526,6 +526,7 @@
(define (walk-statement form env)
(cond
((vector? form) (walk-initializer form env))
((not (list? form)) form)
((null? form) form)
;; expanded here rather than before the walk, so the macro body can
@@ -637,6 +638,17 @@
(cdr form)))))
(convert-arguments (walk-parts form env) env)))))))))
;;; #(struct point : (. p x) 2) -- the values are expressions, and the
;;; words before a `:' a type that is left as written
(define (walk-initializer form env)
(let-values (((prefix rest) (break (lambda (e) (eq? e ':))
(vector->list form))))
(let ((walk (lambda (es) (map (lambda (e) (walk-statement e env)) es))))
(list->vector
(if (null? rest)
(walk prefix)
(append prefix (list ':) (walk (cdr rest))))))))
;;; Is the operand of `sizeof' a type? `(* x)' and `(¤ x i)' are
;;; expressions when x is: a name in scope, or a list that is not
;;; itself a type. A name nothing declared is one only C knows of, and