-
Notifications
You must be signed in to change notification settings - Fork 264
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Title: Non-operator=
out this
function triggers assertion.
Minimal reproducer (https://cpp2.godbolt.org/z/KG7rW4an9):
t: type = {
x: i32 = 0;
operator=: (out this, y: i32) = x = y;
set: (out this, y: i32) = this = y;
}
main: () = {
a: t;
(out a).set(42);
}
Commands:
cppfront -clean-cpp1 main.cpp2
Expected result:
A diagnostic indicating that
a non-operator=
out this
function is not supported, and
to write a non-this
function instead.
Since calling the function would require member access (and thus an object),
a non-operator=
out this
function can't be supported.
It might be possible to make it work.
A non-operator=
out this
function could be lowered to Cpp1 as a friend
.
Then UFCS on (out x).f(args...);
could call it.
Actual result and error:
cppfront: source/parse.h:2787: bool cpp2::function_type_node::is_constructor() const: Assertion `my_decl->has_name("operator=")' failed.
Other observations:
I came up with this after writing a setter.
I was curious as to what would happen if I mis-typed out
instead of inout
.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working