diff options
author | Timothee Cour <timothee.cour2@gmail.com> | 2021-05-09 12:33:32 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-09 21:33:32 +0200 |
commit | f07583588c67f9f3f8dfd7eb44befb5101392d71 (patch) | |
tree | 9b0c2f359b7962d1d8a24f943859b0e4a61c614b /tests/misc/t9039.nim | |
parent | f4dd95f3bee14b69caec63c3be984c4a75f43c8a (diff) | |
download | Nim-f07583588c67f9f3f8dfd7eb44befb5101392d71.tar.gz |
close #9039: compiler does not hang anymore in 1 case involving static params and arrays (#17983)
Diffstat (limited to 'tests/misc/t9039.nim')
-rw-r--r-- | tests/misc/t9039.nim | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/misc/t9039.nim b/tests/misc/t9039.nim new file mode 100644 index 000000000..ba636d1db --- /dev/null +++ b/tests/misc/t9039.nim @@ -0,0 +1,24 @@ +discard """ + action: reject + nimout: ''' +t9039.nim(22, 22) Error: type mismatch: got <array[0..2, int], int, array[0..1, int]> +but expression 'nesting + 1' is of type: int +''' +""" + +# bug #9039; this used to hang in 0.19.0 + + + + + +# line 15 +func default(T: typedesc[array]): T = discard +doAssert default(array[3, int]) == [0, 0, 0] +func shapeBad*[T: not char](s: openarray[T], rank: static[int], nesting = 0, parent_shape = default(array[rank, int])): array[rank, int] = + result = parent_shape + result[nesting] = s.len + when (T is seq|array): + result = shapeBad(s[0], nesting + 1, result) +let a1 = [1, 2, 3].shapeBad(rank = 1) +let a2 = [[1, 2, 3], [4, 5, 6]].shapeBad(rank = 2) |