Closed al6x closed 1 year ago
Would you mind sharing some of your Nim code? Maybe you could trim it down to a point where both your IP is still safe and yet this double declaration still happens. I might have a look at this alleged codegen problem, but having insight into both the Nim and the C code realms would help me a lot!
Regarding having every string interpolated: that would mean that the Nim compiler would have to analyze every string for interpolation then. Not sure how much that would affect compile times, but I reckon it wouldn't be pretty for larger builds...
Please try the code with the devel compiler, which is probably fixed like https://github.com/nim-lang/Nim/issues/20381
@heterodoxic about the Nim code to reproduce it, the code commit 2794581a18891d428b7ac2b16f9b8001a1f2281a with this bug, could be reproduced by running it as nim r keep/main.nim
, please note that there's nim.cfg
, so it's better to run this command from the root of the repo so nim.cfg
will be picked up.
@ringabout thanks, yes could be that this bug is fixed, closing this issue for now. I can't build Nim compiler from sources, some issues on my machine, going to investigate it a bit later, then try to re-build Nim dev version.
Regarding having every string interpolated: that would mean that the Nim compiler would have to analyze every string for interpolation then.
Hmm, I think it should be fast, as Nim would only to scan string bytes for presence of {
character, and only if it present then do the actual interpolation analysis that takes time.
Either using choosenim update devel
or installing from https://github.com/nim-lang/nightlies/releases/tag/2023-05-29-devel-8c55e2999b27e3f088fca2e61739b33498fb07ef is quite convenient.
Description
Nim successfully compiles, then C-compiler crashes. Unfortunately can't isolate bug in short Nim code, but here's C snippet that should help to fix this bug, as you see the
NimStringDesc* fmtRes;
line happens twice and cause problem.The Nim code fix was that I changed from
el(PMessage, (text: fmt"Not found", top: true))
toel(PMessage, (text: "Not found", top: true))
.The C snippet, let me know if you need to see full C-code.
The C stack trace
P.S.
It would be much better if Nim just removed
fmt
and make it language built-in string interpolated. As thefmt
causes lots of problems. Sometimes it just doesn't work, sometimes it can't work inside of some template, sometimes it doesn't work if you combine templates in some way. The reason for that I think is thatfmt
is very frequently used, and so when you write template code, especially if it's multi-level template combination, when you usefmt
it just inflates that complex template code even more, producing all sort of tricky edge cases.Nim Version
Nim Compiler Version 1.6.12 [MacOSX: amd64] Compiled at 2023-03-10 Copyright (c) 2006-2023 by Andreas Rumpf
active boot switches: -d:release -d:nimUseLinenoise
Current Output
No response
Expected Output
No response
Possible Solution
No response
Additional Information
No response