Skip to content

Commit 942b5ba

Browse files
committed
Added regression test case for #148
1 parent b305745 commit 942b5ba

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
template <int i, int j>
3+
auto calc() {
4+
return i + j;
5+
}
6+
7+
fun: (v : _) -> int = {
8+
return inspect v -> int {
9+
is int = calc<1,2>();
10+
is _ = 0;
11+
};
12+
}
13+
14+
main: () -> int = {
15+
return fun(42);
16+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// ----- Cpp2 support -----
2+
#include "cpp2util.h"
3+
4+
#line 1 "mixed-inspect-with-typeof-of-template-arg-list.cpp2"
5+
6+
template <int i, int j>
7+
auto calc() {
8+
return i + j;
9+
}
10+
11+
[[nodiscard]] auto fun(auto const& v) -> int;
12+
#line 14 "mixed-inspect-with-typeof-of-template-arg-list.cpp2"
13+
[[nodiscard]] auto main() -> int;
14+
15+
//=== Cpp2 definitions ==========================================================
16+
17+
#line 6 "mixed-inspect-with-typeof-of-template-arg-list.cpp2"
18+
19+
[[nodiscard]] auto fun(auto const& v) -> int{
20+
return [&] () -> int { auto&& __expr = v;
21+
if (cpp2::is<int>(__expr)) { if constexpr( requires{calc<1,2>();} ) if constexpr( std::is_convertible_v<CPP2_TYPEOF((calc<1,2>())),int> ) return calc<1,2>(); else return int{}; else return int{}; }
22+
else return 0; }
23+
()
24+
; }
25+
26+
[[nodiscard]] auto main() -> int{
27+
return fun(42);
28+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
mixed-inspect-with-typeof-of-template-arg-list.cpp2... ok (mixed Cpp1/Cpp2, Cpp2 code passes safety checks)
2+

0 commit comments

Comments
 (0)