From 5917c2d5b7bda82a8feb521890e255cdf08cf718 Mon Sep 17 00:00:00 2001 From: Bung Date: Mon, 12 Dec 2022 13:26:18 +0800 Subject: fix #15836 proc arg return type auto unexpectly match proc with concr… (#21065) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix #15836 proc arg return type auto unexpectly match proc with concrete type * fix #16244 * add test case for #12869 --- tests/misc/t12869.nim | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 tests/misc/t12869.nim (limited to 'tests/misc/t12869.nim') diff --git a/tests/misc/t12869.nim b/tests/misc/t12869.nim new file mode 100644 index 000000000..731a4e95e --- /dev/null +++ b/tests/misc/t12869.nim @@ -0,0 +1,14 @@ +discard """ + errormsg: "type mismatch: got but expected 'int'" + line: 12 +""" + +import sugar +from algorithm import sorted, SortOrder + +let a = 5 + +proc sorted*[T](a: openArray[T], key: proc(v: T): int, order = SortOrder.Ascending): seq[T] = + sorted(a, (x, y) => key(x) < key(y), order) + +echo sorted(@[9, 1, 8, 2, 6, 4, 5, 0], (x) => (a - x).abs) -- cgit 1.4.1-2-gfad0