From 8d8866c26cb07df3ddc5733cec46d245c7ec5dbc Mon Sep 17 00:00:00 2001 From: Alex Zenla Date: Sat, 26 Jul 2025 00:07:10 -0700 Subject: [PATCH] fix bug with evaluator when calling varadic functions --- .../pork/evaluator/AdaptedNativeProvider.kt | 22 ++++++++++++++++++- support/pork-idea/build.gradle.kts | 2 ++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/evaluator/src/main/kotlin/gay/pizza/pork/evaluator/AdaptedNativeProvider.kt b/evaluator/src/main/kotlin/gay/pizza/pork/evaluator/AdaptedNativeProvider.kt index c7d3ece..8e46ee5 100644 --- a/evaluator/src/main/kotlin/gay/pizza/pork/evaluator/AdaptedNativeProvider.kt +++ b/evaluator/src/main/kotlin/gay/pizza/pork/evaluator/AdaptedNativeProvider.kt @@ -12,7 +12,27 @@ class AdaptedNativeProvider(val provider: NativeProvider) : ExpandedNativeProvid inside: SlabContext ): CallableFunction { val function = provider.provideNativeFunction(definitions) - return CallableFunction { args, _ -> function.invoke(args) } + return CallableFunction { args, _ -> + val argumentsWithLists = mutableListOf() + for ((index, spec) in arguments.withIndex()) { + if (spec.multiple) { + val list = if (index > args.size - 1) { + listOf() + } else { + args.subList(index, args.size) + } + argumentsWithLists.add(list) + break + } + + if (index > args.size - 1) { + break + } + val value = args[index] + argumentsWithLists.add(value) + } + function.invoke(argumentsWithLists) + } } override fun provideNativeFunction(definitions: List): NativeFunction { diff --git a/support/pork-idea/build.gradle.kts b/support/pork-idea/build.gradle.kts index d2668d6..3250f5d 100644 --- a/support/pork-idea/build.gradle.kts +++ b/support/pork-idea/build.gradle.kts @@ -29,6 +29,8 @@ intellijPlatform { sinceBuild = "243" } } + + buildSearchableOptions.set(false) } porkAst {