tstrict_funcs.nim 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. discard """
  2. cmd: "nim c --experimental:strictFuncs --experimental:views $file"
  3. """
  4. import tables, streams, parsecsv
  5. type
  6. Contig2Reads = TableRef[string, seq[string]]
  7. proc get_Contig2Reads(sin: Stream, fn: string, contig2len: TableRef[string, int]): Contig2Reads =
  8. result = newTable[string, seq[string]]()
  9. var parser: CsvParser
  10. open(parser, sin, filename = fn, separator = ' ', skipInitialSpace = true)
  11. while readRow(parser, 2):
  12. if contig2len.haskey(parser.row[1]):
  13. mgetOrPut(result, parser.row[1], @[]).add(parser.row[0])
  14. block:
  15. # issue #15756
  16. func `&&&`[T](x: var seq[T], y: sink T): seq[T] =
  17. newSeq(result, x.len + 1)
  18. for i in 0..x.len-1:
  19. result[i] = move(x[i])
  20. result[x.len] = move(y)
  21. var x = @[0, 1]
  22. let z = x &&& 2
  23. func copy[T](x: var openArray[T]; y: openArray[T]) =
  24. for i in 0..high(x):
  25. x[i] = y[i]
  26. type
  27. R = ref object
  28. a, b: R
  29. data: string
  30. proc main =
  31. var a, b: array[3, R]
  32. b = [R(data: "a"), R(data: "b"), R(data: "c")]
  33. copy a, b
  34. main()