Skip to content

Commit

Permalink
Properly handle incorrect lambdas
Browse files Browse the repository at this point in the history
  • Loading branch information
stirante committed May 17, 2024
1 parent ca30569 commit e213be5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion jsonte/evaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func ParseLambda(text string) ([]string, []string, error) {
p.BuildParseTrees = true
tree := p.Lambda()
if listener.Error != nil {
return nil, nil, burrito.WrapErrorf(listener.Error, "Failed to parse expression \"%s\"", text)
return nil, nil, burrito.WrapErrorf(listener.Error, "Failed to parse lambda \"%s\"", text)
}
visitor := LambdaVisitor{}
visitor.Visit(tree)
Expand Down
5 changes: 4 additions & 1 deletion jsonte/expression_visitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,10 @@ func (v *ExpressionVisitor) VisitObject_field(context *parser.Object_fieldContex
}

func (v *ExpressionVisitor) VisitLambda(ctx *parser.LambdaContext) (types.JsonType, error) {
vars, args, _ := ParseLambda(ctx.GetText())
vars, args, err := ParseLambda(ctx.GetText())
if err != nil {
return types.Null, burrito.PassError(err)
}
return types.NewLambda(
func(this *types.JsonLambda, o []types.JsonType) (types.JsonType, error) {
if len(ctx.AllName()) > len(o) {
Expand Down

0 comments on commit e213be5

Please sign in to comment.