Skip to content

Commit

Permalink
minor fix for right Nothing for operation + (list and map)
Browse files Browse the repository at this point in the history
  • Loading branch information
pchalamet committed Dec 13, 2024
1 parent 120111a commit c5efff9
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/Terrabuild.Expressions/Eval.fs
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,25 @@ let rec eval (context: EvaluationContext) (expr: Expr) =
let res =
match f, values with
| Function.Plus, [Value.String left; Value.String right] -> Value.String (left + right)
| Function.Plus, [Value.Number left; Value.Number right] -> Value.Number (left + right)
| Function.Plus, [Value.Map left; Value.Map right] -> Value.Map (left |> Map.addMap right)
| Function.Plus, [Value.Map left; Value.Nothing] -> Value.Map left
| Function.Plus, [Value.List left; Value.List right] -> Value.List (left @ right)
| Function.Plus, [Value.List left; Value.Nothing] -> Value.List left
| Function.Minus, [Value.Number left; Value.Number right] -> Value.Number (left - right)
| Function.Trim, [Value.String str] -> Value.String (str.Trim())

| Function.Upper, [Value.String str] -> Value.String (str.ToUpperInvariant())
| Function.Upper, [Value.Nothing] -> Value.Nothing

| Function.Trim, [Value.String str] -> Value.String (str.Trim())
| Function.Lower, [Value.String str] -> Value.String (str.ToLowerInvariant())
| Function.Lower, [Value.Nothing] -> Value.Nothing

| Function.Replace, [Value.String str; Value.String value; Value.String newValue] -> Value.String (str.Replace(value, newValue))
| Function.Replace, [Value.Nothing; _; _] -> Value.Nothing

| Function.Plus, [Value.Number left; Value.Number right] -> Value.Number (left + right)
| Function.Minus, [Value.Number left; Value.Number right] -> Value.Number (left - right)

| Function.Plus, [Value.Map left; Value.Map right] -> Value.Map (left |> Map.addMap right)
| Function.Plus, [Value.Nothing; Value.Map right] -> Value.Map right
| Function.Plus, [Value.Map left; Value.Nothing] -> Value.Map left
| Function.Count, [Value.Map map] -> Value.Number map.Count

| Function.Plus, [Value.List left; Value.List right] -> Value.List (left @ right)
| Function.Plus, [Value.Nothing; Value.List right] -> Value.List right
| Function.Plus, [Value.List left; Value.Nothing] -> Value.List left
| Function.Count, [Value.List list] -> Value.Number list.Length

| Function.Not, [Value.Nothing] -> Value.Bool true
Expand Down

0 comments on commit c5efff9

Please sign in to comment.