t9039.nim 682 B

12345678910111213141516171819202122232425
  1. discard """
  2. action: reject
  3. nimout: '''
  4. t9039.nim(22, 22) Error: type mismatch: got <array[0..2, int], int, array[0..1, int]>
  5. but expression 'nesting + 1' is of type: int
  6. '''
  7. """
  8. # bug #9039; this used to hang in 0.19.0
  9. # line 15
  10. func default(T: typedesc[array]): T = discard
  11. doAssert default(array[3, int]) == [0, 0, 0]
  12. func shapeBad*[T: not char](s: openArray[T], rank: static[int], nesting = 0, parent_shape = default(array[rank, int])): array[rank, int] =
  13. result = parent_shape
  14. result[nesting] = s.len
  15. when (T is seq|array):
  16. result = shapeBad(s[0], nesting + 1, result)
  17. let a1 = [1, 2, 3].shapeBad(rank = 1)
  18. let a2 = [[1, 2, 3], [4, 5, 6]].shapeBad(rank = 2)