You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Do not shadow/re-inject fields in child-classes #2573
When assigning to a field which is already defined in one of it's supers, no injection should be used.
Actual Behaviour
Assigning to existing field is not possible as I effectively end up with two fields A.test and B.test.
The only valid workaround I know would be using setters in A.
Just disabling (exact) does not solve the issue, just disable the warning.
Reproduction steps
---@class (exact) A---@fieldtestnumberlocala= {}
functiona:init()
--This is fineself.test=0end---@class (exact) B:Alocalb= {}
functionb:init()
--This is an injection and thus invalidself.test=0end
Additional Notes
If shadowing a field is explicitly wanted, one can still define/type explicitly. But I think by default, no additional field should get injected.
Bumping this issue as it will work when your class object is defined as a local variable, but if it's defined as a global variable it will still give a warning
Activity
Luke100000 commentedon Mar 19, 2024
I added a fix for this, but because I have honestly no idea what I'm doing its probably not a proper solution. It works for me tho: Luke100000@ad80ae9
It effectively disables looking for local field definitions for exact classes. They are invalid anyways afaik.
alex-courtis commentedon Sep 8, 2024
Confirmed fix on 3.10.5.
Inherited fields and types are correctly identified.
Appreciate your work @Luke100000 - I'd me most grateful if you raised a pull request for the fix.
scfmod commentedon Apr 5, 2026
Bumping this issue as it will work when your class object is defined as a local variable, but if it's defined as a global variable it will still give a warning
scfmod commentedon Apr 5, 2026
Also, it seems to break code completion lookup