From 5e7de16a4c4f711f539bff3ea4d022354ac70587 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georges=20Dup=C3=A9ron?= Date: Thu, 11 May 2017 09:45:56 +0200 Subject: [PATCH] Closes #2 (foldl behaves like foldr in some cases) --- typed-map-lib/typed-map/main.rkt | 2 +- typed-map-test/typed-map/test/gh-bug-2.rkt | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 typed-map-test/typed-map/test/gh-bug-2.rkt diff --git a/typed-map-lib/typed-map/main.rkt b/typed-map-lib/typed-map/main.rkt index 8f3963e..15074a2 100644 --- a/typed-map-lib/typed-map/main.rkt +++ b/typed-map-lib/typed-map/main.rkt @@ -85,4 +85,4 @@ upcast-result))))))] [(_ f init-acc lᵢ ...) (with-syntax ([(argᵢ ...) (generate-temporaries #'(lᵢ ...))]) - #'(foldr (λ (argᵢ ... arg-acc) (f argᵢ ... arg-acc)) init-acc lᵢ ...))])) + #'(foldl (λ (argᵢ ... arg-acc) (f argᵢ ... arg-acc)) init-acc lᵢ ...))])) diff --git a/typed-map-test/typed-map/test/gh-bug-2.rkt b/typed-map-test/typed-map/test/gh-bug-2.rkt new file mode 100644 index 0000000..951fe0f --- /dev/null +++ b/typed-map-test/typed-map/test/gh-bug-2.rkt @@ -0,0 +1,9 @@ +#lang typed/racket +(require typed-map + typed/rackunit) + +(check-equal? (foldl (λ (x [acc : (Rec R (U Null (Pairof R Positive-Index)))]) + (cons acc (add1 x))) + '() + '(1 2 3)) + '(((() . 2) . 3) . 4)) \ No newline at end of file