Skip to content

Commit 210b2a0

Browse files
committed
Fix small contract implementation bugs and a signedness test error
1 parent 6f7f09c commit 210b2a0

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

include/cpp2util.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ class contract_group {
401401
constexpr auto has_handler() const -> bool { return reporter != handler{}; }
402402

403403
constexpr auto enforce(bool b, CPP2_MESSAGE_PARAM msg = "" CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT)
404-
-> void { if (!b) reporter(msg CPP2_SOURCE_LOCATION_ARG); }
404+
-> void { if (!b) report_violation(msg CPP2_SOURCE_LOCATION_ARG); }
405405
constexpr auto report_violation(CPP2_MESSAGE_PARAM msg = "" CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAULT)
406406
-> void { if (reporter) reporter(msg CPP2_SOURCE_LOCATION_ARG); }
407407
private:
@@ -515,7 +515,7 @@ auto assert_in_bounds_impl(auto&&, auto&& CPP2_SOURCE_LOCATION_PARAM_WITH_DEFAUL
515515
if (msg) {
516516
err += " and the message \"" + msg + "\"";
517517
}
518-
Type.report_violation( msg );
518+
Type.report_violation( err );
519519
std::terminate();
520520
#else
521521
throw CPP2_FORWARD(x);

regression-tests/pure2-print.cpp2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ outer: @print type = {
9292
tup: std::tuple<Ts...> = ();
9393
}
9494

95-
print: <Args...: type> (inout out: std::ostream, args...: Args) requires sizeof...(Args) >= 0 = {
95+
print: <Args...: type> (inout out: std::ostream, args...: Args) requires sizeof...(Args) >= 0u = {
9696
(out << ... << args);
9797
}
9898

regression-tests/test-results/gcc-10/pure2-print.cpp.output

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ pure2-print.cpp2:9:48: error: template definition of non-template ‘constexpr c
1212
pure2-print.cpp2:67:14: error: no declaration matches ‘void outer::mytype::variadic(const auto:91& ...) requires (is_convertible_v<typename std::remove_cv<typename std::remove_reference<decltype(outer::mytype::variadic::x)>::type>::type, int> && ...)’
1313
pure2-print.cpp2:67:29: note: candidate is: ‘template<class ... auto:90> static void outer::mytype::variadic(const auto:90& ...)’
1414
pure2-print.cpp2:10:19: note: ‘class outer::mytype’ defined here
15-
pure2-print.cpp2:95:37: error: no declaration matches ‘void outer::print(std::ostream&, const Args& ...) requires cpp2::cmp_greater_eq(sizeof (Args)..., 0)’
16-
pure2-print.cpp2:95:37: note: no functions named ‘void outer::print(std::ostream&, const Args& ...) requires cpp2::cmp_greater_eq(sizeof (Args)..., 0)’
15+
pure2-print.cpp2:95:37: error: no declaration matches ‘void outer::print(std::ostream&, const Args& ...) requires cpp2::cmp_greater_eq(sizeof ... (Args ...), 0)’
16+
pure2-print.cpp2:95:37: note: no functions named ‘void outer::print(std::ostream&, const Args& ...) requires cpp2::cmp_greater_eq(sizeof ... (Args ...), 0)’
1717
pure2-print.cpp2:6:7: note: ‘class outer’ defined here

regression-tests/test-results/pure2-print.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ CPP2_REQUIRES_ ((std::is_convertible_v<CPP2_TYPEOF(x), int> && ...)) ;
6666
};
6767

6868
public: template<typename ...Args> static auto print(std::ostream& out, Args const& ...args) -> void
69-
CPP2_REQUIRES_ (cpp2::cmp_greater_eq(sizeof...(Args),0)) ;
69+
CPP2_REQUIRES_ (cpp2::cmp_greater_eq(sizeof...(Args),0u)) ;
7070

7171
#line 99 "pure2-print.cpp2"
7272
public: template<typename ...Args> [[nodiscard]] static auto all(Args const& ...args) -> bool;
@@ -182,7 +182,7 @@ requires ((std::is_convertible_v<CPP2_TYPEOF(x), int> && ...)) {(std::cout << ..
182182

183183
#line 95 "pure2-print.cpp2"
184184
template<typename ...Args> auto outer::print(std::ostream& out, Args const& ...args) -> void
185-
requires (cpp2::cmp_greater_eq(sizeof...(Args),0)) {
185+
requires (cpp2::cmp_greater_eq(sizeof...(Args),0u)) {
186186
#line 96 "pure2-print.cpp2"
187187
(out << ... << args);
188188
}

regression-tests/test-results/pure2-print.cpp2.output

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ outer: type =
139139
print: <Args...: type>(
140140
inout out: std::ostream,
141141
in args...: Args
142-
) requires (sizeof...(Args) >= 0) =
142+
) requires (sizeof...(Args) >= 0u) =
143143
{
144144
(out << ... << args);
145145
}

0 commit comments

Comments
 (0)