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
Description
I tried to write a custom constructor for a @value type.
However, the compilation fails because the member initialization is not recognized
To Reproduce
Minimal example:
test: @value type =
{
val: int;
operator=:(out this, _val : int) = { val = _val; }
}
main: () -> int =
{
x : test = (1);
return 0;
}
Expected Result
A running program.
Actual result
Compiler error:
main.cpp2: error: in operator=, expected 'val = ...' initialization statement (because type scope object 'val' does not have a default initializer)
main.cpp2(3,5): error: see declaration for 'val' here
main.cpp2: error: an operator= body must start with a series of 'member = value;' initialization statements for each of the type-scope objects in the same order they are declared, or the member must have a default initializer (in type 'test')
Adding a default initializer like val: int = 1; works. But according to the diagnostic message the initial code should also work, because of the 'member = value;' initialization statement.
Additional context
I am using g++ 11.4.0 on Linux
The text was updated successfully, but these errors were encountered:
test: type =
{
val: int;
operator=:(
out this,
in _val: int
) =
{
val = _val;
}
operator<=>:(
in this,
in that
) -> move std::strong_ordering;
operator=:(
out this,
in that
) =
{
}
operator=:(out this) =
{
}
}
I think the diagnostic error message for this example is a little bit misleading. However that's also already mentioned in #453 (although due to different reasons). So I will close this ticket.
Description
I tried to write a custom constructor for a @value type.
However, the compilation fails because the member initialization is not recognized
To Reproduce
Minimal example:
Expected Result
A running program.
Actual result
Compiler error:
Adding a default initializer like
val: int = 1;
works. But according to the diagnostic message the initial code should also work, because of the 'member = value;' initialization statement.Additional context
I am using g++ 11.4.0 on Linux
The text was updated successfully, but these errors were encountered: