Skip to content

Linter: "private-access" incorrectly triggers on access from static context within same class #269

Description

@guilhemmgt

Description

The rule private-access is triggered when accessing a private instance member from a static context within the same class. See the example below.

The rule message is "... should not be accessed from outside its class" which let me think this is not intentional and is a bug.

Reproduce

class_name Foo

var _data: int

func _method() -> void:
    pass

static func do(foo: Foo) -> void:
    foo._data = 0
    foo._method()

Expected behaviour

No linter rule triggered.

Observed behaviour

The above example triggers :
[private-access] Private variable '_data' should not be accessed from outside its class
[private-access] Private method '_method' should not be accessed from outside its class

But this is not an access from outside the class...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions