Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UserContext broken with Nim 1.6 #137

Closed
konradmb opened this issue Oct 19, 2021 · 3 comments · Fixed by #138
Closed

UserContext broken with Nim 1.6 #137

konradmb opened this issue Oct 19, 2021 · 3 comments · Fixed by #138

Comments

@konradmb
Copy link
Contributor

Example taken from docs:

import prologue

type
  UserContext = ref object of Context
    data: int

# initialize data
method extend(ctx: UserContext) =
  ctx.data = 999

proc hello*(ctx: UserContext) {.async.} =
  doAssert ctx.data == 999
  resp "<h1>Hello, Prologue!</h1>"

var app = newApp()
app.get("/", hello)
app.run(UserContext)

Error:

contextTest.nim(16, 4) Error: type mismatch: got <Prologue, string, proc (ctx: UserContext): Future[system.void]{.gcsafe, locks: <unknown>.}>
but expected one of:
proc get(app: Prologue; route: string; handler: HandlerAsync; name = "";
         middlewares: openArray[HandlerAsync] = @[])
  first type mismatch at position: 3
  required type for handler: HandlerAsync
  but expression 'hello' is of type: proc (ctx: UserContext): Future[system.void]{.gcsafe, locks: <unknown>.}
5 other mismatching symbols have been suppressed; compile with --showAllMismatches:on to see them

expression: get(app, "/", hello)
@konradmb
Copy link
Contributor Author

Ok, I've done a git bisect:

a7cae2bda24871c55348173816a43144b9e668a5 is the first bad commit
commit a7cae2bda24871c55348173816a43144b9e668a5
Author: Andreas Rumpf <rumpf_a@web.de>
Date:   Thu Sep 2 17:15:11 2021 +0200

    fixes #16325 [backport:1.4] (#18784)

 compiler/sigmatch.nim                             |  3 +--
 tests/overload/tproc_types_dont_like_subtypes.nim | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+), 2 deletions(-)
 create mode 100644 tests/overload/tproc_types_dont_like_subtypes.nim

There is a workaround:
nim-lang/Nim#18828 (comment)

@konradmb konradmb mentioned this issue Oct 19, 2021
ringabout pushed a commit that referenced this issue Oct 20, 2021
* Add ignore for nimble tests

* Update UserContext docs for Nim 1.6

* Add UserContext tests

* var ctx → let ctx
@ringabout ringabout reopened this Oct 20, 2021
@ringabout
Copy link
Member

It seems
/usr/src/prologue/examples/basic/urls.nim(7, 10) needs to be changed too.

konradmb added a commit to konradmb/prologue that referenced this issue Oct 20, 2021
@konradmb
Copy link
Contributor Author

Ok! I don't know why Windows and MacOS CI holds on for eternity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants