#Compiler warnings about a var variable being a constant.

1 messages · Page 1 of 1 (latest)

echo moth
#

I am really new to zig, and for the past couple of days have been trying out optionals and allocators. But now, I ran into an issue where I want to pass in an optional pointer to a function, which will then be checked there and assigned a new pointer value. But I am running into an issue where the compiler is complaining about 2 things: first that a var variable is not being mutated in a test (even though I mutate it in a function that I always run), but it's no big deal since I can just reassign a null value to it again in the test.
The second issue is that when running the test, the compiler complains about assigning a new pointer to a const variable, even though I explicitly set the variable as var in the test.
I was wondering where the issue might have been or how I might fix it.
I attached some images of the code, as well as, of the error. In the message below there is also a zig code file.

gaunt dragon
#

All parameters are constant, you can't modify them

#

so you can't reassign pinit_node

echo moth
#

So I would need to pass a pointer to the pinit_node pointer to solve the problem? That way I should be able to modify the value in the function, correct?

gaunt dragon