Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
termi-official opened this issue Nov 15, 2024 · 0 comments

Comments

@termi-official
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant