-
Notifications
You must be signed in to change notification settings - Fork 249
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: lower (nested) _braced-init-list_ (argument) #927
base: main
Are you sure you want to change the base?
Conversation
assert(board[2] == :std::array<u8, 3> = ('X', 'O', 'O')); | ||
|
||
// Still parentheses | ||
assert((:std::vector = (17, 29)).size() == 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason, a semicolon doesn't work to delimit the unnamed declaration:
assert((:std::vector = (17, 29)).size() == 2); | |
assert(:std::vector = (17, 29);.size() == 2); |
Also, I think (0).f()
should lower to CPP2_UFCS(f)({0})
(despite #542 (comment)),
just like f((0))
lowers to f({0})
.
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
Commit 94bea67 did this for the empty list |
Since now we might want to write flags afterwards, e.g., `<Group, flag1, flag2>`, programmers who want the default group `<Default, flag1, flag2>` might expect to be able to equivalently write `<_, flag1, flag2>`, so let's make that work Until now, programmers would just omit `<Default>` and that continues the work as the basic default, as before
Thanks and sorry for the lag! This seems like it could be pri-3 (per #1287) if it were rebased to current |
28ae3ef
to
774b373
Compare
Rebased. |
@@ -66,7 +66,7 @@ return ret; | |||
|
|||
mystruct::mystruct(auto&& i_, auto&& j_, auto&& k_) | |||
requires (std::is_convertible_v<CPP2_TYPEOF(i_), std::add_const_t<cpp2::i32>&> && std::is_convertible_v<CPP2_TYPEOF(j_), std::add_const_t<std::string>&> && std::is_convertible_v<CPP2_TYPEOF(k_), std::add_const_t<cpp2::u64>&>) | |||
: base{ { 1 } } | |||
: base{ 1 } |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nah, it must be a bug that I don't omit the braces when the context already implies some.
t: @struct type = {
this: std::vector<int> = (0, 1);
v: i32;
}
lowers to
: std::vector<int>{ { 01 } }
(: std::vector<int>{ (01) }
in the main
branch: https://cpp2.godbolt.org/z/srM3vvscM).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that emit_special_member_function
centralizes the lowering of Cpp1 constructors and assignment operators.
#844 (comment) lists some of the bugs from that.
Maybe one of those PRs fixes this particular issue, so I'm leaving it as-is.
Resolves #1343.
Resolves #1283.
Resolves #1037.
Resolves #568.
Resolves #542.
The
main
branch already treats a return type contextually,only lowering a braced-init-list if it can work: https://cpp2.godbolt.org/z/sonKE4zan.
This PR recognizes two other places where an expression list can be an initializer to lower as a braced-init-list: