Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Unary-test behavior with special input variable ? #887

Merged
merged 9 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/main/scala/org/camunda/feel/FeelEngine.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import org.camunda.feel.api.{
import org.camunda.feel.context.{Context, FunctionProvider}
import org.camunda.feel.impl.interpreter.{BuiltinFunctions, EvalContext, FeelInterpreter}
import org.camunda.feel.impl.parser.{ExpressionValidator, FeelParser}
import org.camunda.feel.syntaxtree.{Exp, ParsedExpression, ValError}
import org.camunda.feel.syntaxtree.{Exp, ParsedExpression, ValError, ValFatalError}
import org.camunda.feel.valuemapper.ValueMapper.CompositeValueMapper
import org.camunda.feel.valuemapper.{CustomValueMapper, ValueMapper}

Expand Down Expand Up @@ -181,7 +181,14 @@ class FeelEngine(
failure = Failure(s"failed to evaluate expression '${exp.text}': $cause"),
suppressedFailures = context.failureCollector.failures
)
case value =>

case ValFatalError(cause) =>
FailedEvaluationResult(
failure = Failure(s"failed to evaluate expression '${exp.text}': $cause"),
suppressedFailures = context.failureCollector.failures
)

case value =>
SuccessfulEvaluationResult(
result = valueMapper.unpackVal(value),
suppressedFailures = context.failureCollector.failures
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import org.camunda.feel.syntaxtree.{
ValDateTime,
ValDayTimeDuration,
ValError,
ValFatalError,
ValFunction,
ValList,
ValLocalDateTime,
Expand Down Expand Up @@ -170,8 +171,9 @@ class DefaultValueMapper extends CustomValueMapper {
}.toMap
)

case f: ValFunction => Some(f)
case e: ValError => Some(e)
case f: ValFunction => Some(f)
case e: ValError => Some(e)
case fatalError: ValFatalError => Some(fatalError)

case _ => None
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package org.camunda.feel.impl.builtin

import org.camunda.feel.logger
import org.camunda.feel.syntaxtree.{Val, ValError, ValFunction, ValNull}
import org.camunda.feel.syntaxtree.{Val, ValError, ValFatalError, ValFunction, ValNull}

object BuiltinFunction {

Expand All @@ -34,9 +34,10 @@ object BuiltinFunction {
}

private def error: PartialFunction[List[Val], Any] = {
case args if (args.exists(_.isInstanceOf[ValError])) =>
args.filter(_.isInstanceOf[ValError]).head.asInstanceOf[ValError]
case args =>
case args if args.exists(_.isInstanceOf[ValFatalError]) =>
args.find(_.isInstanceOf[ValFatalError])
case args if args.exists(_.isInstanceOf[ValError]) => args.find(_.isInstanceOf[ValError])
case args =>
val argumentList = args.map("'" + _ + "'").mkString(", ")
ValError(s"Illegal arguments: $argumentList")
}
Expand Down
Loading