Improve loop inference heuristics.

Closes #579
This commit is contained in:
Sam Tobin-Hochstadt 2017-07-13 15:03:58 -04:00
parent 3a7c0b5123
commit 75208f4328
3 changed files with 10 additions and 1 deletions

View File

@ -88,7 +88,8 @@
#:when (free-identifier=? #'val #'e3)
(let ([ts (for/list ([ac (in-syntax #'(actuals ...))]
[f (in-syntax #'(acc ...))])
(let ([type (type-annotation f #:infer #t)])
(let ([type (or (type-annotation f #:infer #t)
(find-annotation #'inner-body f))])
(if type
(tc-expr/check/t ac (ret type))
(generalize (tc-expr/t ac)))))]

View File

@ -130,5 +130,7 @@
(match (single-value #'arg)
[(tc-result1: (List: ts))
(ret (-Tuple (reverse ts)))]
[(tc-result1: (and r (Listof: t)))
(ret r)]
[arg-ty
(tc/funapp #'fun #'(arg) (tc-expr/t #'fun) (list arg-ty) expected)])])))

View File

@ -4015,6 +4015,12 @@
(hfun h)))
(void))
-Void]
;; check that in-naturals works
[tc-e (for/list : (Listof Integer) ([i (in-naturals)]) i) (-lst -Int)]
[tc-e (for/list : (Listof Natural) ([s '(foo bar)]
[i : Natural (in-naturals)])
i)
(-lst -Nat)]
)
(test-suite