Skip to content

Commit b41f60e

Browse files
committed
Change do...while...next to do...next...while
*Breaking change:* `do`...`while`...`next` seems like it should be spelled (and operate as) `do`...`next`...`while` to be easier to reason about Also: - The default message for bounds checks might as well mention the attempted/actual bounds. - Pretty-printing `assert` should have a `;`
1 parent faacec0 commit b41f60e

23 files changed

+132
-111
lines changed

regression-tests/pure2-break-continue.cpp2

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,11 @@ do_continue_inner: () =
9393
}
9494
std::cout << "inner ";
9595
}
96-
while j<3 next j++;
96+
next j++ while j<3;
9797

9898
std::cout << "outer ";
9999
}
100-
while i<3 next i++;
100+
next i++ while i<3;
101101
}
102102

103103
do_continue_outer: () =
@@ -112,11 +112,11 @@ do_continue_outer: () =
112112
}
113113
std::cout << "inner ";
114114
}
115-
while j<3 next j++;
115+
next j++ while j<3;
116116

117117
std::cout << "outer ";
118118
}
119-
while i<3 next i++;
119+
next i++ while i<3;
120120
}
121121

122122
do_break_inner: () =
@@ -131,11 +131,11 @@ do_break_inner: () =
131131
}
132132
std::cout << "inner ";
133133
}
134-
while j<3 next j++;
134+
next j++ while j<3;
135135

136136
std::cout << "outer ";
137137
}
138-
while i<3 next i++;
138+
next i++ while i<3;
139139
}
140140

141141
do_break_outer: () =
@@ -150,11 +150,11 @@ do_break_outer: () =
150150
}
151151
std::cout << "inner ";
152152
}
153-
while j<3 next j++;
153+
next j++ while j<3;
154154

155155
std::cout << "outer ";
156156
}
157-
while i<3 next i++;
157+
next i++ while i<3;
158158
}
159159

160160
for_continue_inner: () =

regression-tests/pure2-intro-example-three-loops.cpp2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ main: () -> int = {
1919

2020
do {
2121
std::cout << std::setw(4) << "**";
22-
} while i* > 1 next i*--;
22+
} next i*-- while i*>0;
2323

2424
std::cout << "\n";
2525
for words do (inout word)

regression-tests/pure2-print.cpp2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ outer: @print type = {
3838

3939
while s.empty() next a() { break; }
4040

41-
do { } while s.empty() next b();
41+
do { } next b() while s.empty();
4242

4343
label: for m next c() do (_) { continue label; }
4444

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Bounds safety violation: out of bounds access attempt detected
1+
Bounds safety violation: out of bounds access attempt detected - attempted index 5, [min,max] range is [0,4]
Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,118 +1,118 @@
11
mixed-bugfix-for-ufcs-non-local.cpp2:13:12: error: a lambda expression cannot appear in this context
22
template<t<CPP2_UFCS_NONLOCAL(f)(o)> _> bool inline constexpr v0 = false;// Fails on GCC ([GCC109781][]) and Clang 12 (a lambda expression cannot appear in this context)
33
^
4-
../../../include/cpp2util.h:856:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
4+
../../../include/cpp2util.h:857:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
55
#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,(),,__VA_ARGS__)
66
^
7-
../../../include/cpp2util.h:837:53: note: expanded from macro 'CPP2_UFCS_'
7+
../../../include/cpp2util.h:838:53: note: expanded from macro 'CPP2_UFCS_'
88
#define CPP2_UFCS_(LAMBDADEFCAPT,QUALID,TEMPKW,...) \
99
^
1010
mixed-bugfix-for-ufcs-non-local.cpp2:15:3: error: a lambda expression cannot appear in this context
1111
t<CPP2_UFCS_NONLOCAL(f)(o)> inline constexpr v1 = t<true>();// Fails on Clang 12 (lambda in unevaluated context).
1212
^
13-
../../../include/cpp2util.h:856:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
13+
../../../include/cpp2util.h:857:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
1414
#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,(),,__VA_ARGS__)
1515
^
16-
../../../include/cpp2util.h:837:53: note: expanded from macro 'CPP2_UFCS_'
16+
../../../include/cpp2util.h:838:53: note: expanded from macro 'CPP2_UFCS_'
1717
#define CPP2_UFCS_(LAMBDADEFCAPT,QUALID,TEMPKW,...) \
1818
^
1919
mixed-bugfix-for-ufcs-non-local.cpp2:21:12: error: a lambda expression cannot appear in this context
2020
template<t<CPP2_UFCS_NONLOCAL(f)(o)> _> auto g() -> void;
2121
^
22-
../../../include/cpp2util.h:856:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
22+
../../../include/cpp2util.h:857:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
2323
#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,(),,__VA_ARGS__)
2424
^
25-
../../../include/cpp2util.h:837:53: note: expanded from macro 'CPP2_UFCS_'
25+
../../../include/cpp2util.h:838:53: note: expanded from macro 'CPP2_UFCS_'
2626
#define CPP2_UFCS_(LAMBDADEFCAPT,QUALID,TEMPKW,...) \
2727
^
2828
mixed-bugfix-for-ufcs-non-local.cpp2:23:36: error: a lambda expression cannot appear in this context
2929
auto g([[maybe_unused]] cpp2::in<t<CPP2_UFCS_NONLOCAL(f)(o)>> unnamed_param_1) -> void;
3030
^
31-
../../../include/cpp2util.h:856:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
31+
../../../include/cpp2util.h:857:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
3232
#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,(),,__VA_ARGS__)
3333
^
34-
../../../include/cpp2util.h:837:53: note: expanded from macro 'CPP2_UFCS_'
34+
../../../include/cpp2util.h:838:53: note: expanded from macro 'CPP2_UFCS_'
3535
#define CPP2_UFCS_(LAMBDADEFCAPT,QUALID,TEMPKW,...) \
3636
^
3737
mixed-bugfix-for-ufcs-non-local.cpp2:27:29: error: a lambda expression cannot appear in this context
3838
[[nodiscard]] auto h() -> t<CPP2_UFCS_NONLOCAL(f)(o)>;
3939
^
40-
../../../include/cpp2util.h:856:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
40+
../../../include/cpp2util.h:857:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
4141
#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,(),,__VA_ARGS__)
4242
^
43-
../../../include/cpp2util.h:837:53: note: expanded from macro 'CPP2_UFCS_'
43+
../../../include/cpp2util.h:838:53: note: expanded from macro 'CPP2_UFCS_'
4444
#define CPP2_UFCS_(LAMBDADEFCAPT,QUALID,TEMPKW,...) \
4545
^
4646
mixed-bugfix-for-ufcs-non-local.cpp2:31:12: error: a lambda expression cannot appear in this context
4747
template<t<CPP2_UFCS_NONLOCAL(f)(o)> _> using a = bool;// Fails on GCC ([GCC109781][]) and Clang 12 (a lambda expression cannot appear in this context)
4848
^
49-
../../../include/cpp2util.h:856:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
49+
../../../include/cpp2util.h:857:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
5050
#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,(),,__VA_ARGS__)
5151
^
52-
../../../include/cpp2util.h:837:53: note: expanded from macro 'CPP2_UFCS_'
52+
../../../include/cpp2util.h:838:53: note: expanded from macro 'CPP2_UFCS_'
5353
#define CPP2_UFCS_(LAMBDADEFCAPT,QUALID,TEMPKW,...) \
5454
^
5555
mixed-bugfix-for-ufcs-non-local.cpp2:33:12: error: a lambda expression cannot appear in this context
5656
template<t<CPP2_UFCS_NONLOCAL(f)(o)> _> auto inline constexpr b = false;// Fails on GCC ([GCC109781][]).
5757
^
58-
../../../include/cpp2util.h:856:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
58+
../../../include/cpp2util.h:857:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
5959
#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,(),,__VA_ARGS__)
6060
^
61-
../../../include/cpp2util.h:837:53: note: expanded from macro 'CPP2_UFCS_'
61+
../../../include/cpp2util.h:838:53: note: expanded from macro 'CPP2_UFCS_'
6262
#define CPP2_UFCS_(LAMBDADEFCAPT,QUALID,TEMPKW,...) \
6363
^
6464
mixed-bugfix-for-ufcs-non-local.cpp2:35:13: error: a lambda expression cannot appear in this context
6565
using c = t<CPP2_UFCS_NONLOCAL(f)(o)>;// Fails on Clang 12 (lambda in unevaluated context) and Clang 12 (a lambda expression cannot appear in this context)
6666
^
67-
../../../include/cpp2util.h:856:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
67+
../../../include/cpp2util.h:857:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
6868
#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,(),,__VA_ARGS__)
6969
^
70-
../../../include/cpp2util.h:837:53: note: expanded from macro 'CPP2_UFCS_'
70+
../../../include/cpp2util.h:838:53: note: expanded from macro 'CPP2_UFCS_'
7171
#define CPP2_UFCS_(LAMBDADEFCAPT,QUALID,TEMPKW,...) \
7272
^
7373
mixed-bugfix-for-ufcs-non-local.cpp2:37:29: error: a lambda expression cannot appear in this context
7474
auto inline constexpr d = t<CPP2_UFCS_NONLOCAL(f)(o)>();// Fails on Clang 12 (lambda in unevaluated context).
7575
^
76-
../../../include/cpp2util.h:856:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
76+
../../../include/cpp2util.h:857:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
7777
#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,(),,__VA_ARGS__)
7878
^
79-
../../../include/cpp2util.h:837:53: note: expanded from macro 'CPP2_UFCS_'
79+
../../../include/cpp2util.h:838:53: note: expanded from macro 'CPP2_UFCS_'
8080
#define CPP2_UFCS_(LAMBDADEFCAPT,QUALID,TEMPKW,...) \
8181
^
8282
mixed-bugfix-for-ufcs-non-local.cpp2:21:12: error: a lambda expression cannot appear in this context
8383
template<t<CPP2_UFCS_NONLOCAL(f)(o)> _> auto g() -> void{}// Fails on GCC ([GCC109781][]) and Clang 12 (a lambda expression cannot appear in this context)
8484
^
85-
../../../include/cpp2util.h:856:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
85+
../../../include/cpp2util.h:857:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
8686
#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,(),,__VA_ARGS__)
8787
^
88-
../../../include/cpp2util.h:837:53: note: expanded from macro 'CPP2_UFCS_'
88+
../../../include/cpp2util.h:838:53: note: expanded from macro 'CPP2_UFCS_'
8989
#define CPP2_UFCS_(LAMBDADEFCAPT,QUALID,TEMPKW,...) \
9090
^
9191
mixed-bugfix-for-ufcs-non-local.cpp2:23:36: error: a lambda expression cannot appear in this context
9292
auto g([[maybe_unused]] cpp2::in<t<CPP2_UFCS_NONLOCAL(f)(o)>> unnamed_param_1) -> void{}// Fails on Clang 12 (lambda in unevaluated context).
9393
^
94-
../../../include/cpp2util.h:856:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
94+
../../../include/cpp2util.h:857:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
9595
#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,(),,__VA_ARGS__)
9696
^
97-
../../../include/cpp2util.h:837:53: note: expanded from macro 'CPP2_UFCS_'
97+
../../../include/cpp2util.h:838:53: note: expanded from macro 'CPP2_UFCS_'
9898
#define CPP2_UFCS_(LAMBDADEFCAPT,QUALID,TEMPKW,...) \
9999
^
100100
mixed-bugfix-for-ufcs-non-local.cpp2:27:29: error: a lambda expression cannot appear in this context
101101
[[nodiscard]] auto h() -> t<CPP2_UFCS_NONLOCAL(f)(o)> { return o; }// Fails on Clang 12 (lambda in unevaluated context).
102102
^
103-
../../../include/cpp2util.h:856:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
103+
../../../include/cpp2util.h:857:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
104104
#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,(),,__VA_ARGS__)
105105
^
106-
../../../include/cpp2util.h:837:53: note: expanded from macro 'CPP2_UFCS_'
106+
../../../include/cpp2util.h:838:53: note: expanded from macro 'CPP2_UFCS_'
107107
#define CPP2_UFCS_(LAMBDADEFCAPT,QUALID,TEMPKW,...) \
108108
^
109109
mixed-bugfix-for-ufcs-non-local.cpp2:41:79: error: lambda expression in an unevaluated operand
110110
inline CPP2_CONSTEXPR bool u::c = [](cpp2::in<std::type_identity_t<decltype(CPP2_UFCS_NONLOCAL(f)(o))>> x) mutable -> auto { return x; }(true);// Fails on Clang 12 (lambda in unevaluated context).
111111
^
112-
../../../include/cpp2util.h:856:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
112+
../../../include/cpp2util.h:857:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
113113
#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,(),,__VA_ARGS__)
114114
^
115-
../../../include/cpp2util.h:837:53: note: expanded from macro 'CPP2_UFCS_'
115+
../../../include/cpp2util.h:838:53: note: expanded from macro 'CPP2_UFCS_'
116116
#define CPP2_UFCS_(LAMBDADEFCAPT,QUALID,TEMPKW,...) \
117117
^
118118
13 errors generated.

regression-tests/test-results/clang-12/pure2-break-continue.cpp.execution

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ while_break_outer:
88
00 inner 01
99

1010
do_continue_inner:
11-
00 inner 01 02 inner 03 inner outer 10 inner 11 12 inner 13 inner outer 20 inner 21 22 inner 23 inner outer 30 inner 31 32 inner 33 inner outer
11+
00 inner 01 02 inner outer 10 inner 11 12 inner outer 20 inner 21 22 inner outer
1212
do_continue_outer:
13-
00 inner 01 10 inner 11 20 inner 21 30 inner 31
13+
00 inner 01 10 inner 11 20 inner 21
1414
do_break_inner:
15-
00 inner 01 outer 10 inner 11 outer 20 inner 21 outer 30 inner 31 outer
15+
00 inner 01 outer 10 inner 11 outer 20 inner 21 outer
1616
do_break_outer:
1717
00 inner 01
1818

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
pure2-bugfix-for-ufcs-noexcept.cpp2:5:26: error: lambda expression in an unevaluated operand
22
static_assert(noexcept(CPP2_UFCS(swap)(t(), t())));// Fails on Clang 12 (lambda in unevaluated context) and GCC 10 (static assertion failed)
33
^
4-
../../../include/cpp2util.h:853:59: note: expanded from macro 'CPP2_UFCS'
4+
../../../include/cpp2util.h:854:59: note: expanded from macro 'CPP2_UFCS'
55
#define CPP2_UFCS(...) CPP2_UFCS_(&,(),,__VA_ARGS__)
66
^
7-
../../../include/cpp2util.h:837:53: note: expanded from macro 'CPP2_UFCS_'
7+
../../../include/cpp2util.h:838:53: note: expanded from macro 'CPP2_UFCS_'
88
#define CPP2_UFCS_(LAMBDADEFCAPT,QUALID,TEMPKW,...) \
99
^
1010
1 error generated.
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
pure2-bugfix-for-ufcs-sfinae.cpp2:1:78: error: lambda expression in an unevaluated operand
22
template<typename T> [[nodiscard]] auto f() -> std::type_identity_t<decltype(CPP2_UFCS_NONLOCAL(a)(T()))>;
33
^
4-
../../../include/cpp2util.h:856:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
4+
../../../include/cpp2util.h:857:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
55
#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,(),,__VA_ARGS__)
66
^
7-
../../../include/cpp2util.h:837:53: note: expanded from macro 'CPP2_UFCS_'
7+
../../../include/cpp2util.h:838:53: note: expanded from macro 'CPP2_UFCS_'
88
#define CPP2_UFCS_(LAMBDADEFCAPT,QUALID,TEMPKW,...) \
99
^
1010
pure2-bugfix-for-ufcs-sfinae.cpp2:1:78: error: lambda expression in an unevaluated operand
1111
template<typename T> [[nodiscard]] auto f() -> std::type_identity_t<decltype(CPP2_UFCS_NONLOCAL(a)(T()))>{}// Fails on Clang 12 (lambda in unevaluated context).
1212
^
13-
../../../include/cpp2util.h:856:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
13+
../../../include/cpp2util.h:857:59: note: expanded from macro 'CPP2_UFCS_NONLOCAL'
1414
#define CPP2_UFCS_NONLOCAL(...) CPP2_UFCS_(,(),,__VA_ARGS__)
1515
^
16-
../../../include/cpp2util.h:837:53: note: expanded from macro 'CPP2_UFCS_'
16+
../../../include/cpp2util.h:838:53: note: expanded from macro 'CPP2_UFCS_'
1717
#define CPP2_UFCS_(LAMBDADEFCAPT,QUALID,TEMPKW,...) \
1818
^
1919
2 errors generated.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Bounds safety violation: out of bounds access attempt detected
1+
Bounds safety violation: out of bounds access attempt detected - attempted index 5, [min,max] range is [0,4]

regression-tests/test-results/gcc-10/pure2-break-continue.cpp.execution

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ while_break_outer:
88
00 inner 01
99

1010
do_continue_inner:
11-
00 inner 01 02 inner 03 inner outer 10 inner 11 12 inner 13 inner outer 20 inner 21 22 inner 23 inner outer 30 inner 31 32 inner 33 inner outer
11+
00 inner 01 02 inner outer 10 inner 11 12 inner outer 20 inner 21 22 inner outer
1212
do_continue_outer:
13-
00 inner 01 10 inner 11 20 inner 21 30 inner 31
13+
00 inner 01 10 inner 11 20 inner 21
1414
do_break_inner:
15-
00 inner 01 outer 10 inner 11 outer 20 inner 21 outer 30 inner 31 outer
15+
00 inner 01 outer 10 inner 11 outer 20 inner 21 outer
1616
do_break_outer:
1717
00 inner 01
1818

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Bounds safety violation: out of bounds access attempt detected
1+
Bounds safety violation: out of bounds access attempt detected - attempted index 5, [min,max] range is [0,4]

0 commit comments

Comments
 (0)