You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] Type with a member and defined operator=: (out this, t : int ) produces an assignment operator with an initializer list #290
changed the title [-][BUG] Type with a member and defined `operator=: (out this, t : int )` produces assignment operator with initialiser list[/-][+][BUG] Type with a member and defined `operator=: (out this, t : int )` produces an assignment operator with an initializer list[/+]on Mar 24, 2023
Activity
[-][BUG] Type with a member and defined `operator=: (out this, t : int )` produces assignment operator with initialiser list[/-][+][BUG] Type with a member and defined `operator=: (out this, t : int )` produces an assignment operator with an initializer list[/+]filipsajdak commentedon Mar 27, 2023
Similarly to #291 you can make this work by resigning from using the default initializer. The following code works:
element: type = { children: std::vector<int>; operator=: (out this, t : int ) = { children = std::vector<int>(); } }also it is worth noting that I would prefer to write:
to initialize
childrenwith values 1,2,3. Unfortunately that generates to the following code:Constructor is fine - it is using initializer list to initialize the vector with 1,2,3. The assignment is bad:
Workaround for this will be using:
That will generate:
hsutter commentedon Apr 1, 2023
Thanks! Fixed.
See also the comment in the closing commit for more information about a Clang warning that my fix now generates, but that I think is spurious.
filipsajdak commentedon Apr 2, 2023
@hsutter I confirmed. The issue is solved!
The warning also appears with my compiler:
Fix default member initialization in assignment, closes hsutter#290
Fix default member initialization in assignment, closes hsutter#290