Skip to content

Commit

Permalink
test: add failing indexed call
Browse files Browse the repository at this point in the history
  • Loading branch information
JohelEGP committed Jan 10, 2024
1 parent 7fff368 commit 1592581
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 0 deletions.
10 changes: 10 additions & 0 deletions regression-tests/pure2-bugfix-for-indexed-call.cpp2
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
f: (_: i32) = { }
main: () = {
array_of_functions: std::array = (f, f);
index := 0;
arguments: i32 = 0;
array_of_functions[index](arguments);
_ = array_of_functions;
_ = index;
_ = arguments;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
In file included from pure2-bugfix-for-indexed-call.cpp:7:
pure2-bugfix-for-indexed-call.cpp2: In function ‘int main()’:
pure2-bugfix-for-indexed-call.cpp2:6:43: error: no match for call to ‘(std::array<void (*)(int), 2>) (cpp2::i32&)’
6 | array_of_functions[index](arguments);
| ~~~~~~~~~~~~~~~ ^
pure2-bugfix-for-indexed-call.cpp2:6:43: error: no match for call to ‘(std::array<void (*)(int), 2>) (cpp2::i32&)’
6 | array_of_functions[index](arguments);
| ~~~~~~~~~~~~~~~ ^
33 changes: 33 additions & 0 deletions regression-tests/test-results/pure2-bugfix-for-indexed-call.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

#define CPP2_IMPORT_STD Yes

//=== Cpp2 type declarations ====================================================


#include "cpp2util.h"

#line 1 "pure2-bugfix-for-indexed-call.cpp2"


//=== Cpp2 type definitions and function declarations ===========================

#line 1 "pure2-bugfix-for-indexed-call.cpp2"
auto f([[maybe_unused]] cpp2::in<cpp2::i32> unnamed_param_1) -> void;
#line 2 "pure2-bugfix-for-indexed-call.cpp2"
auto main() -> int;

//=== Cpp2 function definitions =================================================

#line 1 "pure2-bugfix-for-indexed-call.cpp2"
auto f([[maybe_unused]] cpp2::in<cpp2::i32> unnamed_param_1) -> void{}
#line 2 "pure2-bugfix-for-indexed-call.cpp2"
auto main() -> int{
std::array array_of_functions {f, f};
auto index {0};
cpp2::i32 arguments {0};
CPP2_ASSERT_IN_BOUNDS(array_of_functions(arguments), index);
static_cast<void>(std::move(array_of_functions));
static_cast<void>(std::move(index));
static_cast<void>(std::move(arguments));
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pure2-bugfix-for-indexed-call.cpp2... ok (all Cpp2, passes safety checks)

0 comments on commit 1592581

Please sign in to comment.