Skip to content

[BUG] Constructor with 1 parameter create 2 différentes Cpp1 functions #1408

Open
@MatthieuHernandez

Description

@MatthieuHernandez

When I have a constructor with 1 parameter in Cpp2, a constructor and an operator= are created in Cpp1 and which don't do exactly the same thing, which leads to a compilation error.

This Cpp2 code:

Engine:<Size: i8> type = {

    //...

    public operator=:(out this, playAtariGo: bool) = {
        iterations = 0;
        state: State<Stone, Size> = ();
        states.push_back(state);
        useAtariGoRules = playAtariGo;
    }
 
    //...
}

Give this 2 methods in Cpp1:

#line 26 "../cpp2/engine.h2"
    template <cpp2::i8 Size> Engine<Size>::Engine(cpp2::impl::in<bool> playAtariGo){
        iterations = 0;
        State<Stone,Size> state {}; 
        CPP2_UFCS(push_back)(states, cpp2::move(state));
        useAtariGoRules = playAtariGo;
    }
#line 26 "../cpp2/engine.h2"
    template <cpp2::i8 Size> auto Engine<Size>::operator=(cpp2::impl::in<bool> playAtariGo) -> Engine& {
        goban = {};
        moves = {};
        states = {};
        blackPoint = 0;
        whitePoint = 0;
        useAtariGoRules = false;
        numberOfCapturesToWin = 1;
        blackStonesCaptured = 0;
        whiteStonesCaptured = 0;
#line 27 "../cpp2/engine.h2"
        iterations = 0;
        State<Stone,Size> state {}; 
        CPP2_UFCS(push_back)(states, cpp2::move(state));
        useAtariGoRules = playAtariGo;
        return *this;
#line 31 "../cpp2/engine.h2"
    }
  • First question: Why do I have an operator= in Cpp1 when I didn't use the implicit keyword?
  • Second question: Why are the implementations of the 2 methods not strictly identical?
    In my case the Cpp1 constrctor is correct but the Cpp1 operator= leads to the following error:
./cpp2/engine.h2:27:15: error: overload resolution selected deleted operator '='
   27 |         goban = {};
      |         ~~~~~ ^ ~~

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions