pietroppeter / nimib

nimib 🐳 - nim 👑 driven ⛵ publishing ✍
https://pietroppeter.github.io/nimib/
MIT License
175 stars 10 forks source link

Type mismatch in src/nimib/docs.nim #222

Closed dlesnoff closed 5 months ago

dlesnoff commented 7 months ago

Hello, I get a type mismatch issue in src/nimib/docs.nim with Nim 2.0. I get the following error:

~/Documents/dev/nimib/src/nimib/docs.nim(13, 33) Error: type mismatch
Expression: render(doc)
  [1] doc: NbDoc

Expected one of (first mismatch at [position]):
[1] method render(token: EscapedTag; ctx: Context): string
[1] method render(token: Parent; ctx: Context): string
[1] method render(token: Partial; ctx: Context): string
[1] method render(token: Section; ctx: Context): string
[1] method render(token: Text; ctx: Context): string
[1] method render(token: Token; ctx: Context): string
[1] method render(token: UnescapedTag; ctx: Context): string
[1] proc render(nb: var NbDoc): string
[1] proc render(nb: var NbDoc; blk: var NbBlock): string
[1] proc render(s: string; ctx: Context = newContext()): string
[1] proc render(tokens: seq[Token]; ctx: Context): string

The line in question is in the function:

proc write*(doc: var NbDoc) =
  echo "[nimib] current directory: ", getCurrentDir()
  let dir = doc.filename.splitFile().dir
  if not dir.dirExists:
    echo "[nimib] creating directory: ", dir
    createDir(dir)
  echo "[nimib] saving file: ", doc.filename
  writeFile(doc.filename, render(doc))

I am surprised it didn't match with this entry: [1] proc render(nb: var NbDoc): string. doc is mutable since it is a var argument. EDIT: doc is not mutable -> doc is mutable.

pietroppeter commented 6 months ago

this is indeed weird. does it still reproduce? I am not able at the moment to reproduce locally (have not updated to 2.0 yet...) and CI normally checks 2.0 (this was reported after last CI run but there was not a release in the time this was reported). Incidentally we should add the possibility to rerun the test CI manually, will add an issue about that

dlesnoff commented 5 months ago

The error disappears with Nim 2.0.2. Next time, I'll be more specific in the compilation process, because I could not reproduce the exact error message.