Skip to content

Commit

Permalink
Fix: handle nil value
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkhk committed Sep 10, 2024
1 parent e4904fb commit 0701f76
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/expression/callbacks/standard.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1488,6 +1488,11 @@ defmodule Expression.Callbacks.Standard do
"""
@expression_doc expression: "has_pattern(\"Buy cheese please\", \"buy (\\w+)\")", result: true
@expression_doc expression: "has_pattern(\"Sell cheese please\", \"buy (\\w+)\")", result: false
@expression_doc expression: "has_pattern(nil, \"buy (\\w+)\")", result: false
def has_pattern(nil, _expression, _pattern) do
false
end

def has_pattern(ctx, expression, pattern) do
[expression, pattern] = eval_args!([expression, pattern], ctx)

Expand Down

0 comments on commit 0701f76

Please sign in to comment.