From d48e964950d92a57c24770d40ef0f05ddfe51b7e Mon Sep 17 00:00:00 2001 From: Araq Date: Thu, 11 Oct 2018 19:52:48 +0200 Subject: fixes #9281 --- tests/system/tsystem_misc.nim | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests/system/tsystem_misc.nim') diff --git a/tests/system/tsystem_misc.nim b/tests/system/tsystem_misc.nim index ce36bc9ef..c8189b3b1 100644 --- a/tests/system/tsystem_misc.nim +++ b/tests/system/tsystem_misc.nim @@ -25,6 +25,7 @@ discard """ 55 56 57 +2 ''' """ @@ -102,3 +103,17 @@ proc foo(a: openArray[byte]) = let str = "0123456789" foo(toOpenArrayByte(str, 0, str.high)) + + +template boundedOpenArray[T](x: seq[T], first, last: int): openarray[T] = + toOpenarray(x, max(0, first), min(x.high, last)) + +# bug #9281 + +proc foo[T](x: openarray[T]) = + echo x.len + +let a = @[1, 2, 3] + +# a.boundedOpenArray(1, 2).foo() # Works +echo a.boundedOpenArray(1, 2).len # Internal compiler error -- cgit 1.4.1-2-gfad0