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

Fix #1071 #1259

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions source/reflect.h2
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,15 @@ type_declaration: @copyable type =
return ret;
}

has_default_ctor: (this) -> bool = {
for this.get_member_functions()
do (mf)
if mf.is_default_constructor() {
return true;
}
return false;
}

query_declared_value_set_functions: (this)
-> (
out_this_in_that : bool,
Expand Down Expand Up @@ -843,16 +852,21 @@ basic_value: (inout t: meta::type_declaration) =
{
t.copyable();

has_default_ctor := false;
for t.get_member_functions() do (inout mf) {
has_default_ctor |= mf.is_default_constructor();
mf.require( !mf.is_protected() && !mf.is_virtual(),
"a value type may not have a protected or virtual function");
"a value type may not have a protected or virtual function" );
mf.require( !mf.is_destructor() || mf.is_public() || mf.is_default_access(),
"a value type may not have a non-public destructor");
"a value type may not have a non-public destructor" );
}

if !has_default_ctor {
if !t.has_default_ctor() {
for t.get_member_objects() do (in mo) {
mo.require(
mo.has_initializer() || /* if cpp2 type: */ mo./* get the type declaration */.has_default_ctor()
/* else: defer check to cpp1 compiler using std::is_default_constructible */,
"a value type must be default constructible"
);
}
t.add_member( "operator=: (out this) = { }");
}
}
Expand Down
Loading