tobject_assign.nim 968 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # bug #16706
  2. block: # reduced example
  3. type
  4. A = object of RootObj
  5. a0: string
  6. B = object
  7. b0: seq[A]
  8. var c = newSeq[A](2)
  9. var d = B(b0: c)
  10. when true: # original example
  11. import std/[options, tables, times]
  12. type
  13. Data* = object
  14. shifts*: OrderedTable[int64, Shift]
  15. balance*: float
  16. Shift* = object
  17. quoted*: bool
  18. date*: DateTime
  19. description*: string
  20. start*: Option[DateTime]
  21. finish*: Option[DateTime]
  22. breakTime*: Option[Duration]
  23. rate*: float
  24. qty: Option[float]
  25. id*: int64
  26. let shift = Shift(
  27. quoted: true,
  28. date: parse("2000-01-01", "yyyy-MM-dd"),
  29. description: "abcdef",
  30. start: none(DateTime),
  31. finish: none(DateTime),
  32. breakTime: none(Duration),
  33. rate: 462.11,
  34. qty: some(10.0),
  35. id: getTime().toUnix()
  36. )
  37. var shifts: OrderedTable[int64, Shift]
  38. shifts[shift.id] = shift
  39. discard Data(
  40. shifts: shifts,
  41. balance: 0.00
  42. )