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

toMD5 does not work at compile time but documentation claims otherwise #19305

Closed
metagn opened this issue Jan 1, 2022 · 0 comments · Fixed by #19307
Closed

toMD5 does not work at compile time but documentation claims otherwise #19305

metagn opened this issue Jan 1, 2022 · 0 comments · Fixed by #19307

Comments

@metagn
Copy link
Collaborator

metagn commented Jan 1, 2022

md5 docs says "Note: The procs in this module can be used at compile time.". However, toMD5 does not work.

Example

import md5

static:
  block working:
    doAssert(getMD5("Franz jagt im komplett verwahrlosten Taxi quer durch Bayern") ==
      "a3cca2b2aa1e3b5b3b5aad99a8529074")
    doAssert(getMD5("Frank jagt im komplett verwahrlosten Taxi quer durch Bayern") ==
      "7e716d0e702df0505fc72e2b89467910")
  block failing:
    doAssert($toMD5("") == "d41d8cd98f00b204e9800998ecf8427e")
    discard toMD5("")

Current Output

nim/lib/system/memory.nim(21, 5) Error: cannot 'importc' variable at compile time; c_memset

Expected Output

compiles

Possible Solution

Looking at the code, there is no reason for md5 to use cstring/pointer behavior. There is already some use of openarray so it's puzzling why it doesn't use openarray in place of cstring/pointer as well, the buffer used is an array[0..63, uint8]. Same seems to go for endians/oids/sha1.

Additional Information

$ nim -v
Nim Compiler Version 1.6.2
@ringabout ringabout added the Documentation Content Related to documentation content (not generation). label Jan 1, 2022
@ringabout ringabout removed the Documentation Content Related to documentation content (not generation). label Jan 2, 2022
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