1
0
forked from alex-eg/sex

tell what a member path walked from the fields it has left

This commit is contained in:
2026-10-14 20:09:49 +03:00
parent c97ae8583b
commit 44101c0c06

View File

@@ -1121,20 +1121,17 @@
(let ((base (second form)))
(let step ((expr (walk-operand base env))
(type (expression-type base env))
(read (list)) ; the fields walked, reversed
(fields (cddr form))
(told? #f))
(if (null? fields)
(copy-form-source! form expr)
(let ((target (pointer-target type)))
(unless (or type told?)
(sex-warning form "cannot type this; `.' reads it as a value"
(if (null? read)
base
`(|.| ,base ,@(reverse read)))))
(let ((walked (drop-right (cddr form) (length fields))))
(sex-warning form "cannot type this; `.' reads it as a value"
(if (null? walked) base `(|.| ,base ,@walked)))))
(step (list (if target '%-> 'dot-access) expr (car fields))
(field-type (or target type) (car fields))
(cons (car fields) read)
(cdr fields)
(or told? (not type))))))))