Error: shadowing declaration is deprecated
Ary Manzana
ary at esperanto.org.ar
Sun Dec 24 15:19:59 PST 2006
jicman escribió:
> == Quote from Bill Baxter's article
>> jicman wrote:
>>> Greetings!
>>>
>>> this code,
>>>
>>> foreach(char[] u; FPUsers)
>>> {
>>>
>>> }
>>>
>>> results in,
>>>
>>> Error: shadowing declaration jic.libs.FPSDK.FindUser.u is
> deprecated.
>>> Will anyone explain this to me? I tried to do a search on it,
> but I couldn't
>>> anything related to this. Found other integer arrays, but
> nothing about
>>> char[]. Any help would be greatly appreciated. Thanks.
>>>
>>> jos�
>> It means you have another variable named 'u' in the same function
>> declared somewhere before that foreach loop. The theory is that
> many
>> times these are bugs, and when they are they can be hard to spot.
>> I'm not totally enamored with the feature myself, since I don't
> recall
>> ever really been bitten by it, but I have happily shadowed
> variables in
>> the past when it suited me. Especially little dummy
> counter/placeholder
>> variables like your 'c' above.
>> But anyway, that's what the error means. Just rename 'c' to c2 or
> cc or d.
>> --bb
>
> Ok, I'll buy that, but this is not working either:
>
> char[] u;
> foreach(u; FPUsers)
> {
> }
>
> That should work.
But probably in your code there is some other variable "u" defined,
previous to the "char[] u" line. Check that.
Cheers,
Ary
More information about the Digitalmars-d-learn
mailing list