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: lower (nested) _braced-init-list_ (argument) #927

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions regression-tests/pure2-hashable.cpp2
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ base: @struct @hashable type = {
}

mystruct: @struct @hashable type = {
this: base = (1);
this: base = 1;
i: i32;
j: std::string;
k: u64;
Expand All @@ -12,4 +12,4 @@ mystruct: @struct @hashable type = {
main: () = {
x: mystruct = (2, "three", 4u);
std::cout << x.hash();
}
}
2 changes: 1 addition & 1 deletion regression-tests/test-results/pure2-hashable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Copy link
Contributor Author

@JohelEGP JohelEGP Oct 4, 2024

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).

Copy link
Contributor Author

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.

, i{ CPP2_FORWARD(i_) }
, j{ CPP2_FORWARD(j_) }
, k{ CPP2_FORWARD(k_) }{}
Expand Down
Loading