tmust_compile.nim 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. discard """
  2. output: '''success'''
  3. """
  4. # bug #6682
  5. {.experimental: "notnil".}
  6. type
  7. Fields = enum
  8. A=1, B, C
  9. Obj = object
  10. fld: array[Fields, int]
  11. AsGeneric[T] = array[Fields, T]
  12. Obj2[T] = object
  13. fld: AsGeneric[T]
  14. var a: Obj # this works
  15. var arr: array[Fields, int]
  16. var b = Obj() # this doesn't (also doesn't works with additional fields)
  17. var z = Obj2[int]()
  18. echo "success"
  19. # bug #6555
  20. import tables
  21. type
  22. TaskOrNil = ref object
  23. Task = TaskOrNil not nil
  24. let table = newTable[string, Task]()
  25. table.del("task")
  26. # bug #6121
  27. import json
  28. type
  29. foo = object
  30. thing: ptr int not nil
  31. CTS = ref object
  32. subs_by_sid: Table[int, foo]
  33. proc parse(cts: CTS, jn: JsonNode) =
  34. var y = jn.getInt(4523)
  35. let ces = foo(
  36. thing: addr y
  37. )
  38. cts.subs_by_sid[0] = ces
  39. # bug #6489
  40. proc p(x: proc(){.closure.} not nil) = discard
  41. p(proc(){.closure.} = discard)
  42. # bug #6490
  43. proc p2(a: proc()) =
  44. if a.isNil:
  45. raise newException(ValueError, "a is nil")
  46. else:
  47. let b: proc() not nil = a
  48. p2(writeStackTrace)