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 f0a1b6712f
commit ab4fdc54f3
5 changed files with 59 additions and 2 deletions

View File

@@ -7,7 +7,8 @@
"unsized of a pointer: 5"
"named bound: 2 4 b"
"unnamed parameters: 7 -1 2"
"typedefs: hi 4 2")
"typedefs: hi 4 2"
"sizeof a pointer type: 1 1")
(return 0)
;;; Three questions about a written type that used to be answered in
@@ -89,4 +90,9 @@
(var v vec4 #(1.0 2.0 3.0 4.0))
(var op unary twice)
(printf "typedefs: %s %zu %d\n" greeting (/ (sizeof v) (sizeof (¤ v 0))) (op 1))
;; `(* T)' is a type or a dereference, and only what is in scope says
(printf "sizeof a pointer type: %d %d\n"
(== (sizeof (* const char)) (sizeof greeting))
(== (sizeof (* greeting)) 1))
(return 0))