status-im / nim-chronos

Chronos - An efficient library for asynchronous programming
https://status-im.github.io/nim-chronos/docs/chronos
Apache License 2.0
352 stars 51 forks source link

chronos/threadsync errors when compiling documentation #499

Open PhilippMDoerner opened 4 months ago

PhilippMDoerner commented 4 months ago

The Problem

I've recently tried to compile docs of a project of mine which makes use of the chronos/threadsync module in 2 places.

I've come to notice that it is impossible to compile the module docs for any module that imports threadsync.

Minimal example

  1. Have the following nim file
    # src/playground.nim
    import chronos/threadsync
  2. Run the command nim doc src/playground.nim

The error

This will lead to the following error message:

/home/philipp/dev/playground/nimbledeps/pkgs2/chronos-4.0.0-2b7b9c774b0fb8c3b1d415da6148c8973c4ba81c/chronos/threadsync.nim(138, 12) Error: type mismatch
Expression: contains(loop, fd)
  [1] loop: PDispatcher
  [2] fd: AsyncFD

Expected one of (first mismatch at [position]):
[1] func contains(self: Opt; v: auto): bool
[1] func contains[T](x: set[T]; y: T): bool
[1] proc contains[T](a: openArray[T]; item: T): bool
[1] proc contains[T](deq: Deque[T]; item: T): bool
[1] proc contains[U, V, W](s: HSlice[U, V]; value: W): bool

/home/philipp/dev/playground/nimbledeps/pkgs2/chronos-4.0.0-2b7b9c774b0fb8c3b1d415da6148c8973c4ba81c/chronos/threadsync.nim(138, 21) Error: expression '' has no type (or is ambiguous)
/home/philipp/dev/playground/nimbledeps/pkgs2/chronos-4.0.0-2b7b9c774b0fb8c3b1d415da6148c8973c4ba81c/chronos/threadsync.nim(276, 5) template/generic instantiation of `async` from here
/home/philipp/dev/playground/nimbledeps/pkgs2/chronos-4.0.0-2b7b9c774b0fb8c3b1d415da6148c8973c4ba81c/chronos/threadsync.nim(340, 20) Error: type mismatch
Expression: contains(loop, AsyncFD(eventFd))
  [1] loop: PDispatcher
  [2] AsyncFD(eventFd): AsyncFD

Expected one of (first mismatch at [position]):
[1] func contains(self: Opt; v: auto): bool
[1] func contains[T](x: set[T]; y: T): bool
[1] proc contains[T](a: openArray[T]; item: T): bool
[1] proc contains[T](deq: Deque[T]; item: T): bool
[1] proc contains[U, V, W](s: HSlice[U, V]; value: W): bool

/home/philipp/dev/playground/nimbledeps/pkgs2/chronos-4.0.0-2b7b9c774b0fb8c3b1d415da6148c8973c4ba81c/chronos/threadsync.nim(276, 5) template/generic instantiation of `async` from here
/home/philipp/dev/playground/nimbledeps/pkgs2/chronos-4.0.0-2b7b9c774b0fb8c3b1d415da6148c8973c4ba81c/chronos/threadsync.nim(340, 12) Error: type mismatch: got 'uint8' for 'not' but expected 'bool'
/home/philipp/dev/playground/nimbledeps/pkgs2/chronos-4.0.0-2b7b9c774b0fb8c3b1d415da6148c8973c4ba81c/chronos/threadsync.nim(368, 7) template/generic instantiation of `async` from here
/home/philipp/dev/playground/nimbledeps/pkgs2/chronos-4.0.0-2b7b9c774b0fb8c3b1d415da6148c8973c4ba81c/chronos/threadsync.nim(410, 16) Error: type mismatch
Expression: contains(loop, AsyncFD(eventFd))
  [1] loop: PDispatcher
  [2] AsyncFD(eventFd): AsyncFD

Expected one of (first mismatch at [position]):
[1] func contains(self: Opt; v: auto): bool
[1] func contains[T](x: set[T]; y: T): bool
[1] proc contains[T](a: openArray[T]; item: T): bool
[1] proc contains[T](deq: Deque[T]; item: T): bool
[1] proc contains[U, V, W](s: HSlice[U, V]; value: W): bool

/home/philipp/dev/playground/nimbledeps/pkgs2/chronos-4.0.0-2b7b9c774b0fb8c3b1d415da6148c8973c4ba81c/chronos/threadsync.nim(368, 7) template/generic instantiation of `async` from here
/home/philipp/dev/playground/nimbledeps/pkgs2/chronos-4.0.0-2b7b9c774b0fb8c3b1d415da6148c8973c4ba81c/chronos/threadsync.nim(410, 8) Error: type mismatch: got 'uint8' for 'not' but expected 'bool'
/home/philipp/dev/playground/src/playground.nim(1, 15) Warning: imported and not used: 'threadsync' [UnusedImport]

I'm not entirely sure what this is all about, potentially some macro magic that makes it not find the contains proc via the doc command (?)