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

Error: 'newHttpHeaders' can have side effects #15851

Closed
juancarlospaco opened this issue Nov 5, 2020 · 5 comments
Closed

Error: 'newHttpHeaders' can have side effects #15851

juancarlospaco opened this issue Nov 5, 2020 · 5 comments

Comments

@juancarlospaco
Copy link
Collaborator

Examples

$ nim c --experimental:strictFuncs Nim/lib/pure/httpcore.nim
Nim/lib/pure/httpcore.nim(122, 6) Error: 'newHttpHeaders' can have side effects

$

Current Output

Error: 'newHttpHeaders' can have side effects

Possible Solution

Make newHttpHeaders back to proc.

Additional Information

System Information

{
  "compiled": "2020-10-20T01:21:43",
  "NimVersion": "1.5.1",
  "hostCPU": "amd64",
  "hostOS": "linux",
  "cpuEndian": "littleEndian",
  "getTempDir": "/tmp/",
  "now": "2020-11-05T10:37:07-03:00",
  "getCurrentEncoding": "UTF-8",
  "getFreeMem": 397312,
  "getTotalMem": 528384,
  "getOccupiedMem": 68400,
  "countProcessors": 4,
  "arch": "x86_64",
  "FileSystemCaseSensitive": true,
  "nimcacheDir": "/home/juan/.cache/nim/nimbug_r",
  "ccompilerPath": "",
  "currentCompilerExe": "/home/juan/.choosenim/toolchains/nim-1.4.0/bin/nim",
  "nimpretty": "0.2",
  "nimble": "nimble v0.12.0 compiled at 2020-10-30 00:39:01\ngit hash: couldn't determine git hash",
  "nimgrep": "1.5",
  "nimsuggest": "Nim Compiler Version 1.5.1 [Linux: amd64]\nCompiled at 2020-10-30\nCopyright (c) 2006-2020 by Andreas Rumpf\n\ngit hash: 33e258c72fe9c06410b30c5bc4364626c4f6ecb1\nactive boot switches: -d:release -d:danger --gc:markAndSweep",
  "choosenim": "choosenim v0.7.2 (2020-10-17 14:56:03) [linux/amd64]",
  "gcc": "gcc (GCC) 10.2.0",
  "clang": "clang version 10.0.1",
  "git": "2.29.2",
  "node": "v15.1.0",
  "python": "3.8.6",
  "ssd": true
}

Proposed Labels

minor, easy
@ringabout
Copy link
Member

Thanks!
I will revert some func to proc.

@Araq
Copy link
Member

Araq commented Nov 5, 2020

@xflywind It seems wiser to override the compiler's analysis with a {.cast(noSideEffect).}: block.

@ringabout

This comment has been minimized.

ringabout added a commit to ringabout/Nim that referenced this issue Nov 5, 2020
@Araq Araq closed this as completed in 218ff27 Nov 6, 2020
@dom96
Copy link
Contributor

dom96 commented Nov 7, 2020

The commit that caused this bug shouldn't have been merged, why wasn't running nim c --experimental:strictFuncs Nim/lib/pure/httpcore.nim part of the test plan? Do we have other files that need to be checked?

@ringabout
Copy link
Member

ringabout commented Nov 7, 2020

testament already has tests/effects/tstrict_funcs.nim to test strictfuncs.

Have added it in last pull request.
https://github.com/nim-lang/Nim/pull/15852/files

I don't know whether we should document that and where to document it?

narimiran pushed a commit that referenced this issue Nov 9, 2020
* fix #15851

* {.cast(noSideEffect).}

(cherry picked from commit 218ff27)
PMunch pushed a commit to PMunch/Nim that referenced this issue Jan 6, 2021
* fix nim-lang#15851

* {.cast(noSideEffect).}
mildred pushed a commit to mildred/Nim that referenced this issue Jan 11, 2021
* fix nim-lang#15851

* {.cast(noSideEffect).}
irdassis pushed a commit to irdassis/Nim that referenced this issue Mar 16, 2021
* fix nim-lang#15851

* {.cast(noSideEffect).}
ardek66 pushed a commit to ardek66/Nim that referenced this issue Mar 26, 2021
* fix nim-lang#15851

* {.cast(noSideEffect).}
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

4 participants