Skip to content

Static property getter emits static int limit() const in C++ (does not compile), and Python ignores IsStatic on properties #180

Open

Description

@matt-edmondson

What's wrong

C++:

  • StandardLanguageGenerator.Separated (Coder/Languages/StandardLanguageGenerator.cs:549-556) lowers a property getter with IsReadOnly = true even when IsStatic is set.
  • CppGenerator (Coder/Languages/CppGenerator.cs:216-219) then writes const whenever IsReadOnly is set.
  • A static member function cannot be cv-qualified.

Python: PythonGenerator (Coder/Languages/PythonGenerator.cs:108-152) never reads declaration.IsStatic for properties, so it always writes an instance @property.

Failure scenario

Input: PropertyDeclaration("Limit", int) { IsStatic = true, HasGetter = true } with getter body return 10, inside class Counter.

  • C++: the output is static int limit() const { return 10; }. g++ -std=c++20 fails with "static member function 'static int Counter::limit()' cannot have cv-qualifier".
  • Python: the output is @property def Limit(self). Counter.Limit evaluates to the property object, not 10.

Suggested fix

  • In Separated, set IsReadOnly = !property.IsStatic. Also guard the C++ const with !funcDecl.IsStatic, which covers a hand-built static, read-only FunctionDeclaration too.
  • Python: lower a static property to @staticmethod getter and setter functions, as the C, Rust and Go paths do, or write it as inexpressible.

Acceptance criteria

  • The C++ compile tests include a static property with a getter, and it compiles.
  • A Python test shows that a static property is reachable from the class.

Activity

  1. matt-edmondson commented on Oct 6, 2026

    @matt-edmondson
    ContributorAuthor

    Triage

    • Category: Bug (generated code does not compile, wrong semantics)
    • Priority: Medium. Generated C++ for a static property getter fails to compile. Generated Python runs but returns the wrong value: it gives the property object instead of the value.
    • Area / suggested owner: Property lowering (StandardLanguageGenerator.Separated), CppGenerator, PythonGenerator.
    • Duplicates / in progress: Not a duplicate. No open PR covers it (open PR fix(PythonGenerator): map 'long' type to 'int' (#109) #124 touches PythonGenerator, but only the long type mapping).

    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions