1
0
forked from alex-eg/sex

type an operator's result without qualifiers

The spelling was the first operand's, so (+ k 1) with k const was a
const int and (+ 1 k) was not; a value has no qualifiers either way.
This commit is contained in:
2026-10-16 17:04:20 +03:00
parent 47b98e41df
commit ad1825e8a8
3 changed files with 27 additions and 2 deletions

View File

@@ -1391,8 +1391,10 @@
;;;
;;; (var p _ (+ a 1)) a : (¤ int 4) -> int * p = a + 1;
;;; not int p[4] = a + 1;
;;; An operator gives a value, which has no qualifiers: (+ k 1) with
;;; k : (const int) is an int, whichever side k is on
(define (decayed written type)
(if (array-type? type) (unparse-type (decay type)) written))
(if (array-type? type) (unparse-type (decay type)) (value-type written)))
(define (promoted-type written)
(and written (promoted written (underlying (parse-type written)))))
@@ -1402,7 +1404,10 @@
(any (lambda (word) (memq word '(char short bool _Bool)))
(prim-name type)))
'int
written))
(value-type written)))
(define (value-type written)
(unparse-type (unqualified (parse-type written))))
;;; `char' and `short' promote to `int', so the ranks start there
(define (conversion-rank type)