In C, at least, I believe shadowing a higher scoped variable takes effect from the moment of declaration.
Okay, I did not know that.
'>
That's a pretty easy one to work around anyway as shadowing variables like that is generally not great programming practice '>
Yeah, I usually have -Wshadow enabled (and -Werror to boot), since I hate having those in my code.
something like
int x = x + 1; in main produces the same thing. It adds 1 to the local stack variable. It does not deference the global x and then add 1 to
that.
In C (and C++), that direct case from the script, a local variable with the same name as a parameter, is not allowed, as far as I'm aware.
I would have thought, though, that a local variable would shadow a global (or a class member variable in C++) after the initialization, but it seems I was wrong. I learned something new today, then, thanks.
'>
Googling this, I found a quote from the C standard
in this Stack Overflow reply. Yup, "immediately after its complete declarator (Clause
and before its initializer".
So not a bug in the compiler, except for maybe eating this script without a least issuing a warning. No idea what the original BioWare compiler did there, of course. The OpenKnights' nwnnsscomp does warn there, at least.