diff --git a/pkl-core/src/main/java/org/pkl/core/ast/member/FunctionNode.java b/pkl-core/src/main/java/org/pkl/core/ast/member/FunctionNode.java index 2aa7e19b0..ad61e85de 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/member/FunctionNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/member/FunctionNode.java @@ -181,7 +181,7 @@ public final class FunctionNode extends RegularMemberNode { assert argCount != paramCount; return exceptionBuilder() - .evalError("wrongFunctionArgumentCount", paramCount, argCount, paramCount == 1 ? "" : "s") + .evalError("wrongFunctionArgumentCount", paramCount, argCount) .withSourceSection(member.getHeaderSection()) .build(); } diff --git a/pkl-core/src/main/java/org/pkl/core/ast/type/IdentityMixinNode.java b/pkl-core/src/main/java/org/pkl/core/ast/type/IdentityMixinNode.java index b171ec3aa..fc91c26e8 100644 --- a/pkl-core/src/main/java/org/pkl/core/ast/type/IdentityMixinNode.java +++ b/pkl-core/src/main/java/org/pkl/core/ast/type/IdentityMixinNode.java @@ -57,7 +57,7 @@ public final class IdentityMixinNode extends PklRootNode { if (arguments.length != 3) { CompilerDirectives.transferToInterpreter(); throw exceptionBuilder() - .evalError("wrongFunctionArgumentCount", 1, arguments.length - 2, "") + .evalError("wrongFunctionArgumentCount", 1, arguments.length - 2) .withSourceSection(sourceSection) .build(); } diff --git a/pkl-core/src/main/resources/org/pkl/core/errorMessages.properties b/pkl-core/src/main/resources/org/pkl/core/errorMessages.properties index bebb45b91..62827c693 100644 --- a/pkl-core/src/main/resources/org/pkl/core/errorMessages.properties +++ b/pkl-core/src/main/resources/org/pkl/core/errorMessages.properties @@ -207,7 +207,7 @@ expectedModuleAsArgument=\ Expected a module as argument, but got an object that amends a module. wrongTypeArgumentCount=\ -Expected {0} type argument(s) but got {1}. +Expected {0} type argument{0,choice,0#s|1#|1 a1 -res = f.applyToList(List(1, 2, 3, 4, 5, 6)) \ No newline at end of file +f = (a1, a2) -> a1 +res = f.applyToList(List(1, 2, 3, 4, 5, 6)) diff --git a/pkl-core/src/test/files/LanguageSnippetTests/output/lambdas/wrongArgumentListLength.err b/pkl-core/src/test/files/LanguageSnippetTests/output/lambdas/wrongArgumentListLength.err index 9310729b5..8c1f640ba 100644 --- a/pkl-core/src/test/files/LanguageSnippetTests/output/lambdas/wrongArgumentListLength.err +++ b/pkl-core/src/test/files/LanguageSnippetTests/output/lambdas/wrongArgumentListLength.err @@ -1,8 +1,8 @@ –– Pkl Error –– -Expected 3 function arguments but got 6. +Expected 2 function arguments but got 6. -x | f = (a1, a2, a3) -> a1 - ^^^^^^^^^^^^^^^^^^ +x | f = (a1, a2) -> a1 + ^^^^^^^^^^^^^^ at wrongArgumentListLength#f. (file:///$snippetsDir/input/lambdas/wrongArgumentListLength.pkl) x | res = f.applyToList(List(1, 2, 3, 4, 5, 6)) diff --git a/pkl-executor/src/test/kotlin/org/pkl/executor/EmbeddedExecutorTest.kt b/pkl-executor/src/test/kotlin/org/pkl/executor/EmbeddedExecutorTest.kt index 8c5ee5fad..3e5963fa2 100644 --- a/pkl-executor/src/test/kotlin/org/pkl/executor/EmbeddedExecutorTest.kt +++ b/pkl-executor/src/test/kotlin/org/pkl/executor/EmbeddedExecutorTest.kt @@ -530,8 +530,27 @@ class EmbeddedExecutorTest { timeout(Duration.ofSeconds(1)) } } + assertThat(e.message) + .containsAnyOf( + "Evaluation timed out after 1 second.", + "Evaluation timed out after 1 second(s).", + ) - assertThat(e.message).contains("Evaluation timed out after 1 second(s).") + val e2 = + assertThrows { + executor.evaluatePath(pklFile) { + allowedModules("file:") + allowedResources("prop:") + rootDir(tempDir) + timeout(Duration.ofMillis(1500)) + } + } + + assertThat(e2.message) + .containsAnyOf( + "Evaluation timed out after 1.5 seconds.", + "Evaluation timed out after 1.5 second(s).", + ) } @Test