type a value if as the join of its branches
It had no rule, so _ could not be set from one.
This commit is contained in:
@@ -846,6 +846,16 @@ whitespace aside, THEN?"
|
||||
"a function's types are written out"))
|
||||
;; a call was typed by asking the global table what a function of
|
||||
;; that name returns, which a local pointer is not
|
||||
;; a value if had no rule either: it is the join of its values
|
||||
(test-assert "a value if joins its branches"
|
||||
(emits? (in-fn "(var x _ (if a 1 2.5))") "double x = a ? 1 : 2.5"))
|
||||
(test-assert "every one of a chain"
|
||||
(emits? (in-fn "(var x _ (if a 1 b 2 3.5f))") "float x"))
|
||||
(test-assert "an aggregate as itself"
|
||||
(emits? "(struct pt ((x int))) (fn f ((a int) (p (struct pt))) void (var q _ (if a p p)))"
|
||||
"struct pt q = a ? p : p"))
|
||||
(test-assert "and none when a branch says nothing"
|
||||
(reports? (in-fn "(var x _ (if a (unheard-of) 1))") "infer"))
|
||||
;; none of these had a rule
|
||||
(test-assert "#t is a bool, as true is"
|
||||
(emits? (in-fn "(var t _ #t)") "bool t = 1"))
|
||||
|
||||
Reference in New Issue
Block a user