infer a global's type before its braces lose theirs

A global's initializer was stripped to plain braces before `_' was
solved, so #(point : 2 3) left nothing to infer point from.
This commit is contained in:
2026-10-19 15:33:37 +03:00
parent a0b323980f
commit a885c21b9b
2 changed files with 15 additions and 14 deletions

View File

@@ -1876,15 +1876,15 @@
;; from ;; from
(core (if (eq? 'extern qualifier) (core (if (eq? 'extern qualifier)
core core
(resolve-wildcard (let ((solved (resolve-wildcard
(copy-form-source! (copy-form-source!
core core
(if (> (length core) 3) (if (> (length core) 3)
(append (take core 3) (append (take core 3)
(map bare-braces (walk-operands core (drop core 3) env))
(walk-operands core (drop core 3) env))) core))
core)) env)))
env))) (copy-form-source! solved (map bare-braces solved)))))
(form (if qualifier (form (if qualifier
(copy-form-source! resolved (cons qualifier core)) (copy-form-source! resolved (cons qualifier core))
core))) core)))

View File

@@ -1,6 +1,6 @@
(compilation "-- -std=c11 -pedantic-errors") (compilation "-- -std=c11 -pedantic-errors")
(input) (input)
(output "c11: 42 43 6 4 6") (output "c11: 42 43 6 4 6 12")
(return 0) (return 0)
;;; C11 is the floor, and this is the program that holds it there: the ;;; C11 is the floor, and this is the program that holds it there: the
@@ -23,8 +23,9 @@
(sum shape ((square ((side int))) (dot ()))) (sum shape ((square ((side int))) (dot ())))
(var corner point #(point : 2 3)) (var corner _ #(point : 2 3))
(var unit shape (shape/square 1)) (var unit _ (shape/square 1))
(var pair [_ 2] #(#(point : 1 2) #(point : 3 4)))
(fn sides ((s shape)) int (fn sides ((s shape)) int
(var n int 0) (var n int 0)
@@ -38,7 +39,7 @@
(var k int 1) (var k int 1)
(var add-k (closure ((int)) int) (var add-k (closure ((int)) int)
(closure ((v int)) int (k) (return (+ v k)))) (closure ((v int)) int (k) (return (+ v k))))
(printf "c11: %d %d %d %d %d\n" (printf "c11: %d %d %d %d %d %d\n"
(.area p) (add-k (.area p)) (+ (sides (shape/square 1)) (sides (shape/dot)) 2) (.area p) (add-k (.area p)) (+ (sides (shape/square 1)) (sides (shape/dot)) 2)
(sides unit) (.area corner)) (sides unit) (.area corner) (.area [pair 1]))
(return 0)) (return 0))