diff --git a/src/arkreactor/Compiler/Lowerer/ASTLowerer.cpp b/src/arkreactor/Compiler/Lowerer/ASTLowerer.cpp index ac983aa85..947dc8441 100644 --- a/src/arkreactor/Compiler/Lowerer/ASTLowerer.cpp +++ b/src/arkreactor/Compiler/Lowerer/ASTLowerer.cpp @@ -359,6 +359,8 @@ namespace Ark::internal buildAndThrowError(fmt::format("Can not use {} with less than 2 arguments", name), head); if (std::cmp_greater(argc, MaxValue16Bits)) buildAndThrowError(fmt::format("Too many arguments ({}), exceeds {}", argc, MaxValue16Bits), x); + if (argc != 2 && (inst == POP_LIST || inst == POP_LIST_IN_PLACE)) + buildAndThrowError(fmt::format("Expected 2 arguments (list, index) for {}, got {}", name, argc), head); if (argc != 3 && inst == SET_AT_INDEX) buildAndThrowError(fmt::format("Expected 3 arguments (list, index, value) for {}, got {}", name, argc), head); if (argc != 4 && inst == SET_AT_2_INDEX) diff --git a/tests/unittests/resources/DiagnosticsSuite/compileTime/pop_list_in_place_too_many_args.ark b/tests/unittests/resources/DiagnosticsSuite/compileTime/pop_list_in_place_too_many_args.ark new file mode 100644 index 000000000..700b4b8d2 --- /dev/null +++ b/tests/unittests/resources/DiagnosticsSuite/compileTime/pop_list_in_place_too_many_args.ark @@ -0,0 +1,2 @@ +(mut a [0 1 2 3]) +(pop! a 0 1 2 3) diff --git a/tests/unittests/resources/DiagnosticsSuite/compileTime/pop_list_in_place_too_many_args.expected b/tests/unittests/resources/DiagnosticsSuite/compileTime/pop_list_in_place_too_many_args.expected new file mode 100644 index 000000000..d823a23e3 --- /dev/null +++ b/tests/unittests/resources/DiagnosticsSuite/compileTime/pop_list_in_place_too_many_args.expected @@ -0,0 +1,6 @@ +In file tests/unittests/resources/DiagnosticsSuite/compileTime/pop_list_in_place_too_many_args.ark:2 + 1 | (mut a [0 1 2 3]) + 2 | (pop! a 0 1 2 3) + | ^~~~ + 3 | + Expected 2 arguments (list, index) for pop!, got 5 diff --git a/tests/unittests/resources/DiagnosticsSuite/compileTime/pop_list_too_many_args.ark b/tests/unittests/resources/DiagnosticsSuite/compileTime/pop_list_too_many_args.ark new file mode 100644 index 000000000..c7b70b070 --- /dev/null +++ b/tests/unittests/resources/DiagnosticsSuite/compileTime/pop_list_too_many_args.ark @@ -0,0 +1,2 @@ +(mut a [0 1 2 3]) +(pop a 0 1 2 3) diff --git a/tests/unittests/resources/DiagnosticsSuite/compileTime/pop_list_too_many_args.expected b/tests/unittests/resources/DiagnosticsSuite/compileTime/pop_list_too_many_args.expected new file mode 100644 index 000000000..2e7696883 --- /dev/null +++ b/tests/unittests/resources/DiagnosticsSuite/compileTime/pop_list_too_many_args.expected @@ -0,0 +1,6 @@ +In file tests/unittests/resources/DiagnosticsSuite/compileTime/pop_list_too_many_args.ark:2 + 1 | (mut a [0 1 2 3]) + 2 | (pop a 0 1 2 3) + | ^~~ + 3 | + Expected 2 arguments (list, index) for pop, got 5