Skip to content

Codegen for global variable setter does not check if assignment is defined #65

@termi-official

Description

@termi-official

MWE

source file

class A {
public:
  explicit A(const char* person = "World"): person_(person){}
  void say_hello() const{
    std::cout << "Hello " << person_ << "!\n";
  }
  A& operator=(const A& a) = delete;
private:
  std::string person_;
};

A global_variable;

codegen

// [...]
void add_methods() const{
    auto& t = module_;

    DEBUG_MSG("Adding global_variable methods to provide access to the global variable global_variable (" __HERE__ ")");
    // defined in ./A.h:17:3
    t.method("global_variable", []()-> A& { return global_variable; });
    t.method("global_variable!", [](const A& val)-> A& { return global_variable = val; });
  }
// [...]

The generated code does not compile, because the statement global_variable = val is invalid, as the assignment operation has been deleted. Codegen should skip generating the setter method in this case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions