let sizeof take a type that looks like an expression

(* char) is a pointer type and (* p) a dereference, and only the names
in scope tell them apart, so semen decides and marks a type for the
writer. Before, both were walked as expressions: sizeof(*char).

Fixes #52.
This commit is contained in:
2026-10-09 16:04:00 +03:00
parent d5b003ef91
commit 08044ce4a1
5 changed files with 59 additions and 2 deletions

View File

@@ -202,6 +202,9 @@ forms, and what remains."
;; name `->' itself being the threading macro
(('%-> . rest) (cons '%-> (map walk-expr rest)))
(('var . _) (walk-var form))
;; semen has told a type from an expression; only it knows the names
;; in scope that make `(* p)' one or the other
(('sizeof ('%type type)) `(%sizeof-type ,(walk-type type)))
;; semen has already put the target first, the way C writes it
(('typedef type name)
`(typedef ,(walk-type type) ,(atom-to-fmt-c name)))