-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: lower (nested) _braced-init-list_ (argument)
- Loading branch information
Showing
7 changed files
with
159 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
point: @value type = { | ||
public x: int = 0; | ||
public y: int = 0; | ||
operator=: (implicit out this, x_: int, y_: int) = { | ||
x = x_; | ||
y = y_; | ||
} | ||
} | ||
|
||
check: (p: point) p; | ||
|
||
main: () = { | ||
assert(check((17, 29)).x == 17); | ||
assert(check((17, 29)).y == 29); | ||
|
||
board: std::array<std::array<u8, 3>, 3> = (( | ||
('O', 'X', 'O'), | ||
(' ', ('X'), 'X'), | ||
('X', 'O', 'O') | ||
)); | ||
assert(board[0] == :std::array<u8, 3> = ('O', 'X', 'O')); | ||
assert(board[1] == :std::array<u8, 3> = (' ', 'X', 'X')); | ||
assert(board[2] == :std::array<u8, 3> = ('X', 'O', 'O')); | ||
|
||
// Still parentheses (for now?) | ||
assert((:std::vector = (17, 29)).size() == 2); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
regression-tests/test-results/pure2-bugfix-for-nested-lists.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
|
||
#define CPP2_IMPORT_STD Yes | ||
|
||
//=== Cpp2 type declarations ==================================================== | ||
|
||
|
||
#include "cpp2util.h" | ||
|
||
#line 1 "pure2-bugfix-for-nested-lists.cpp2" | ||
class point; | ||
#line 2 "pure2-bugfix-for-nested-lists.cpp2" | ||
|
||
|
||
//=== Cpp2 type definitions and function declarations =========================== | ||
|
||
#line 1 "pure2-bugfix-for-nested-lists.cpp2" | ||
class point { | ||
#line 2 "pure2-bugfix-for-nested-lists.cpp2" | ||
public: int x {0}; | ||
public: int y {0}; | ||
public: point(cpp2::impl::in<int> x_, cpp2::impl::in<int> y_); | ||
public: [[nodiscard]] auto operator<=>(point const& that) const& -> std::strong_ordering = default; | ||
public: point(point const& that); | ||
|
||
public: auto operator=(point const& that) -> point& ; | ||
public: point(point&& that) noexcept; | ||
public: auto operator=(point&& that) noexcept -> point& ; | ||
public: explicit point(); | ||
|
||
#line 8 "pure2-bugfix-for-nested-lists.cpp2" | ||
}; | ||
|
||
[[nodiscard]] auto check(cpp2::impl::in<point> p) -> auto; | ||
|
||
auto main() -> int; | ||
|
||
//=== Cpp2 function definitions ================================================= | ||
|
||
#line 1 "pure2-bugfix-for-nested-lists.cpp2" | ||
|
||
#line 4 "pure2-bugfix-for-nested-lists.cpp2" | ||
point::point(cpp2::impl::in<int> x_, cpp2::impl::in<int> y_) | ||
: x{ x_ } | ||
, y{ y_ }{ | ||
|
||
#line 7 "pure2-bugfix-for-nested-lists.cpp2" | ||
} | ||
|
||
|
||
point::point(point const& that) | ||
: x{ that.x } | ||
, y{ that.y }{} | ||
|
||
auto point::operator=(point const& that) -> point& { | ||
x = that.x; | ||
y = that.y; | ||
return *this;} | ||
point::point(point&& that) noexcept | ||
: x{ std::move(that).x } | ||
, y{ std::move(that).y }{} | ||
auto point::operator=(point&& that) noexcept -> point& { | ||
x = std::move(that).x; | ||
y = std::move(that).y; | ||
return *this;} | ||
point::point(){} | ||
#line 10 "pure2-bugfix-for-nested-lists.cpp2" | ||
[[nodiscard]] auto check(cpp2::impl::in<point> p) -> auto { return p; } | ||
|
||
#line 12 "pure2-bugfix-for-nested-lists.cpp2" | ||
auto main() -> int{ | ||
if (cpp2::cpp2_default.is_active() && !(check({ 17, 29 }).x == 17) ) { cpp2::cpp2_default.report_violation(""); } | ||
if (cpp2::cpp2_default.is_active() && !(check({ 17, 29 }).y == 29) ) { cpp2::cpp2_default.report_violation(""); } | ||
|
||
std::array<std::array<cpp2::u8,3>,3> board {{ { | ||
'O', 'X', 'O' }, { | ||
' ', { 'X' }, 'X' }, { | ||
'X', 'O', 'O' } }}; | ||
|
||
if (cpp2::cpp2_default.is_active() && !(CPP2_ASSERT_IN_BOUNDS_LITERAL(board, 0) == std::array<cpp2::u8,3>{'O', 'X', 'O'}) ) { cpp2::cpp2_default.report_violation(""); } | ||
if (cpp2::cpp2_default.is_active() && !(CPP2_ASSERT_IN_BOUNDS_LITERAL(board, 1) == std::array<cpp2::u8,3>{' ', 'X', 'X'}) ) { cpp2::cpp2_default.report_violation(""); } | ||
if (cpp2::cpp2_default.is_active() && !(CPP2_ASSERT_IN_BOUNDS_LITERAL(cpp2::move(board), 2) == std::array<cpp2::u8,3>{'X', 'O', 'O'}) ) { cpp2::cpp2_default.report_violation(""); } | ||
|
||
// Still parentheses (for now?) | ||
if (cpp2::cpp2_default.is_active() && !(CPP2_UFCS(size)((std::vector{17, 29})) == 2) ) { cpp2::cpp2_default.report_violation(""); } | ||
} | ||
|
2 changes: 2 additions & 0 deletions
2
regression-tests/test-results/pure2-bugfix-for-nested-lists.cpp2.output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pure2-bugfix-for-nested-lists.cpp2... ok (all Cpp2, passes safety checks) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters