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:
@@ -614,6 +614,15 @@
|
||||
(test-assert "and says it once, solved to a type already saying it"
|
||||
(emits? (in-fn "(var k (const int) 1) (var p (* const _) (& k))")
|
||||
"const int * p = &k"))
|
||||
;; an operator's result is a value, which has no qualifier -- the
|
||||
;; spelling was the first operand's, so it had one only that way round
|
||||
(test-assert "a sum is unqualified"
|
||||
(emits? (in-fn "(var k (const int) 1) (var j _ (+ k 1))") " int j = k + 1"))
|
||||
(test-assert "whichever side the qualified operand is on"
|
||||
(emits? (in-fn "(var k (const int) 1) (var j _ (+ 1 k))") " int j = 1 + k"))
|
||||
(test-assert "and so is a pointer it gives"
|
||||
(emits? (in-fn "(var s (* char) 0) (var p (const * char) s) (var q _ (+ p 1))")
|
||||
"char * q = p + 1"))
|
||||
;; a compound literal carries its own type, where a brace
|
||||
;; initializer has none and takes one from its context
|
||||
(test-assert "a compound literal answers a bare wildcard"
|
||||
|
||||
Reference in New Issue
Block a user