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

[Question] can't use nimword in proc #19

Closed
ITwrx opened this issue Dec 11, 2023 · 3 comments
Closed

[Question] can't use nimword in proc #19

ITwrx opened this issue Dec 11, 2023 · 3 comments

Comments

@ITwrx
Copy link

ITwrx commented Dec 11, 2023

hi,
I'm having trouble trying to use nimword's isValidPassword in Guildenstern.
I'm trying: let compareResult = password.isValidPassword(registeredUser.password) (inside a try block) and i'm still getting the dreaded:

Error: type mismatch
Expression: newHttpServer(handlePost)
  [1] handlePost: proc (){.gcsafe.}

Expected one of (first mismatch at [position]):
[1] proc newHttpServer(onrequestcallback: proc () {.gcsafe, nimcall, raises: [].};
                   loglevel = LogLevel.WARN; parserequestline = true;
                   hascontent = true): HttpServer

Any ideas about what is going on?
Thanks

@ITwrx
Copy link
Author

ITwrx commented Dec 12, 2023

maybe because nimword's encodedHash variable is not marked as a {.threadvar.} for thread safety?

@PhilippMDoerner
Copy link

PhilippMDoerner commented Dec 13, 2023

Your handlePost is missing both the nimcall pragma and doesn't explicitly state that it never raises an Exception (that's what raises:[] means). It should get those implicitly, but you can't know that if there's something you missed that would make your proc not have those.

Note that isValidPassword states: {.raises: {UnknownAlgorithmError, ValueError, Pbkdf2Error, SodiumError, Exception}.} =
So unless you catch all of those and in the end also the general "Exception" this can not work. This is where a minimal example for confirmation would help 😛

@ITwrx
Copy link
Author

ITwrx commented Dec 13, 2023

@PhilippMDoerner thanks for your answer. I responded in the nimword issue.

@ITwrx ITwrx closed this as completed Dec 13, 2023
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

No branches or pull requests

2 participants