Skip to content

Commit 84296f6

Browse files
committed
test: add test case for another limitation
1 parent e0c9019 commit 84296f6

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

regression-tests/pure2-last-use.cpp2

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,14 @@ draw: () = {
164164
_ = (pos).vertex();
165165
}
166166

167+
union: type = {
168+
destroy: (inout this) = { }
169+
operator=: (move this) = {
170+
// destroy(); FIXME Discarding `this` still moves it here.
171+
_ = this;
172+
}
173+
}
174+
167175
my_string: @struct type = {
168176
string: std::string;
169177
size: std::size_t = string.size();

regression-tests/test-results/pure2-last-use.cpp

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ class issue_869;
2525

2626

2727
#line 167 "pure2-last-use.cpp2"
28+
class cpp2_union;
29+
30+
31+
#line 175 "pure2-last-use.cpp2"
2832
class my_string;
2933

3034

@@ -157,6 +161,17 @@ auto issue_888(std::string r, int size) -> void;
157161
auto draw() -> void;
158162

159163
#line 167 "pure2-last-use.cpp2"
164+
class cpp2_union {
165+
public: auto destroy() & -> void;
166+
public: ~cpp2_union() noexcept;
167+
public: cpp2_union() = default;
168+
public: cpp2_union(cpp2_union const&) = delete; /* No 'that' constructor, suppress copy */
169+
public: auto operator=(cpp2_union const&) -> void = delete;
170+
171+
172+
#line 173 "pure2-last-use.cpp2"
173+
};
174+
160175
class my_string {
161176
public: std::string string;
162177
public: std::size_t size {CPP2_UFCS(size)(string)};
@@ -354,10 +369,17 @@ auto draw() -> void{
354369
static_cast<void>(CPP2_UFCS_MOVE(vertex)((std::move(pos))));
355370
}
356371

357-
#line 172 "pure2-last-use.cpp2"
372+
#line 168 "pure2-last-use.cpp2"
373+
auto cpp2_union::destroy() & -> void{}
374+
cpp2_union::~cpp2_union() noexcept{
375+
// destroy(); FIXME Discarding `this` still moves it here.
376+
static_cast<void>(std::move((*this)));
377+
}
378+
379+
#line 180 "pure2-last-use.cpp2"
358380
auto main(int const argc_, char** argv_) -> int{
359381
auto const args = cpp2::make_args(argc_, argv_);
360-
#line 173 "pure2-last-use.cpp2"
382+
#line 181 "pure2-last-use.cpp2"
361383
issue_683(args);
362384
issue_847_2(std::vector<std::unique_ptr<int>>());
363385
}

0 commit comments

Comments
 (0)