KEMBAR78
Member variable "up" causes name collision · Issue #933 · mypyc/mypyc · GitHub
Skip to content

Member variable "up" causes name collision #933

@olsoneric

Description

@olsoneric

The member variable name up causes a collision with the generated c function MyClass_setup. This causes an error during C compile time. This is mainly a coincidence that set + up is the same as setup.

Version: mypy 0.950 (compiled: yes) with MSVC++ 19.21.27702.2 for x64
Edit: also confirmed with mypy 0.970+dev.74b35bef35ad5a7b1aa635f52ffcfd850eadc589.dirty (compiled: no)


Example
Running mypyc on this python class:

class MyClass:
    def __init__(self, arg1):
        self.up = arg1

produces this generated C function:
static int MyClass_setup(example1___MyClassObject *self, PyObject *value, void *closure);

which conflicts with the existing MyClass_setup function that is generated for classes:
static PyObject *MyClass_setup(PyTypeObject *type);


Expected behavior
A member variable "up" would not cause a collision. For example, other variable names like this:

class MyClass:
    def __init__(self, arg1):
        self.membervar1 = arg1

produce generated code like this:
static int MyClass_setmembervar1(example1___MyClassObject *self, PyObject *value, void *closure);
which does not conflict with other function names.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions