Skip to content

Commit

Permalink
Merge pull request #887 from camunda/864-unary-test-implicit-null
Browse files Browse the repository at this point in the history
fix: Unary-test behavior with special input variable `?`
  • Loading branch information
saig0 authored Aug 23, 2024
2 parents 3248428 + ac4737b commit 0fddf7d
Show file tree
Hide file tree
Showing 10 changed files with 991 additions and 855 deletions.
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
6 changes: 4 additions & 2 deletions src/main/scala/org/camunda/feel/impl/DefaultValueMapper.scala
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

0 comments on commit 0fddf7d

Please sign in to comment.