I'm very new to nim and am getting
Error: type mismatch: got <proc (){.locks: 0.}> but expected 'proc (){.gcsafe, locks: 0.}'
on the line var my_seq = @[foo, bar] where both foo and bar are nullary with no return values.
I wasn't able to find anyone else who got this error in the forums.
Using nim version 1.4.6
Some other questions
I can post these separately if that's better.
To your currently hit issue it seems the difference is one is not gcSafe which you can force by adding {.gcSafe.} for example proc someName(somVal: T): SomeRetType{.gcSafe.}.
2: you can do --hintSource:on in your global config to enable source printing.
3: You can do `end` to strop
4: You can echo var.type, most editor support you can hover values.
Is --hotcodereloading:on still well supported?
It never was well supported, I'm afraid. Maybe we need to make this clearer in the documentation.
Thanks everyone!
2: you can do --hintSource:on in your global config to enable source printing.
invalid command line option: '--hintSource'.
I didn't any similar https://nim-lang.org/docs/nimc.html (anything with src seems to be doc related). And config files seems to only store extra command line parameters?
It never was well supported, I'm afraid.
Ah, that's unfortunate. I think this was one of the only dynamic features. Does using dynlib/dlopen work well? Are modules able to find each other's proc and vars if they are all Nim?
On 3, yes you can strop and in some case you have to use stropping, but it is awkward to use when you need the name often
That's my throught when reading about strop. I'll likely end up adding or removing a letter, though this makes the different choices for different keywords somewhat arbitrary.
Ah sorry it is --hint[source]:on. What gcsafe annotation does is override the analysis that says whether it touches gc'd memory. To prevent this issue from appearing again you can follow this, it also does show the types of the procs so you can see their effects.
var a = @[100, 200]
type YourProc = proc()
proc doThing() =
echo a[0]
a[0] = 300
proc doOtherThing =
echo 100 + 30
echo doThing.type, doOtherThing.type
var b = @[doThing.YourProc, doOtherThing]
Thanks, again.
So --hint[source]:on gives me the source line for compiler warnings and errors, but not for runtime errors and explicit calls to getStackTrace.
To prevent this issue from appearing again you can follow this
Ah, I see so .<type> is some kind of type conversion since doThing.YourProc.type is YourProc and (3.14).int is 3.
When I was still adding {.gcsafe}, there were some compiler warnings that these functions were gcunsafe. Should I be worried when converting these functions and calling them?
But maybe the problem is me.
Well, you do use Nixos, so... :P
I'd like to note that none of this is an actionable statement.
If you want help, minimal examples to produce the problem would be the way to go, so that either you can get correction suggestions or it turns out that this is an actual bug and it turns into a github issue.