diff --git a/src/tests/util/list.cpp b/src/tests/util/list.cpp index 75d4c3a7c..d065c6791 100644 --- a/src/tests/util/list.cpp +++ b/src/tests/util/list.cpp @@ -202,6 +202,13 @@ static void tst15() { list({1, 2, 2, 2, 3, 4})); } +static void tst16() { + list l({1, 2, 3, 4}); + lean_assert_eq(map(l, [](int i) { return i + 10; }), + list({11, 12, 13, 14})); + lean_assert_eq(map(list(), [](int i) { return i + 10; }), list()); +} + int main() { tst1(); tst2(); @@ -218,5 +225,6 @@ int main() { tst13(); tst14(); tst15(); + tst16(); return has_violations() ? 1 : 0; } diff --git a/src/util/list_fn.h b/src/util/list_fn.h index 814cd31a9..3dffd7b10 100644 --- a/src/util/list_fn.h +++ b/src/util/list_fn.h @@ -152,7 +152,7 @@ list map(list const & l, F && f) { --i; r = cons(f(tmp[i]->head()), r); } - return l; + return r; } }