read every trailing array bound as a dimension

[m 1 2] lost its second index, and [int 2 3] came out int 2 x[3]. Each
index now subscripts what the one before it gave, and [int 2 3] declares
what it indexes, int[2][3]. An inline struct's fields, once more than
one bound was looked for, were taken for one; their shape tells them apart.
This commit is contained in:
2026-10-16 15:26:05 +03:00
parent ba807fe9ec
commit 08cb8451ff
7 changed files with 102 additions and 14 deletions

View File

@@ -8,7 +8,8 @@
"named bound: 2 4 b"
"unnamed parameters: 7 -1 2"
"typedefs: hi 4 2"
"sizeof a pointer type: 1 1")
"sizeof a pointer type: 1 1"
"dimensions: 6 12 5")
(return 0)
;;; Three questions about a written type that used to be answered in
@@ -95,4 +96,9 @@
(printf "sizeof a pointer type: %d %d\n"
(== (sizeof (* const char)) (sizeof greeting))
(== (sizeof (* greeting)) 1))
;; [int 2 3] is two rows of three, indexed [g row column]
(var g [int 2 3] #(#(0 1 2) #(3 4 5)))
(printf "dimensions: %zu %zu %d\n"
(/ (sizeof g) (sizeof int)) (sizeof [g 0]) [g 1 2])
(return 0))