fix four conditional operands sexc emitted without parentheses, and mark every Sex workaround with a TODO

A conditional as an operand loses its parentheses (sex#59): box-blur
allocated a quarter of its buffer, deep water got the shallow colour,
and verify's delta histogram wrote out of bounds into the height
classes. Plan.org quoted the corrupted count.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 21:01:59 +03:00
parent 39b0e74f2b
commit c14c154303
22 changed files with 156 additions and 5 deletions

View File

@@ -10,6 +10,9 @@
;;; every RNG call is the mod's: it is what the layout depends on.
(include stdlib.h string.h math.h)
;; TODO sex#58: import only the modules used here once an import brings
;; the types its interface needs; until then, every dependency, in
;; dependency order.
(import maps)
(import lcg)
(import noise)
@@ -148,7 +151,11 @@
(var dy double (- (. end y) (. start y)))
(var v double (+ (* (- (. p x) (. start x)) dx) (* (- (. p y) (. start y)) dy)))
(/= v (+ (* dx dx) (* dy dy)))
(return (cast (if (< v 0) 0 (if (> v 1) 1 v)) float)))
;; TODO sex#59: clamp inside the cast once a conditional operand
;; keeps its parentheses.
(if (< v 0) (= v 0))
(if (> v 1) (= v 1))
(return (cast v float)))
(fn distance-to-line ((p vec2) (s vec2) (e vec2)) double
(if (<= (+ (* (- (. s x) (. e x)) (- (. p x) (. e x))) (* (- (. s y) (. e y)) (- (. p y) (. e y)))) 0)
@@ -474,6 +481,7 @@
(var n int (. p config zones-in-region))
(var best-x int x)
(var best-z int z)
;; TODO sex#63: write -INFINITY once it reads as a negation.
(var best double (- INFINITY))
(var found bool false)
(for (var dx int -1) (<= dx 1) (++ dx)