Skip to content

Commit

Permalink
Merge pull request #212 from MasonM/fix-calling-function-ident
Browse files Browse the repository at this point in the history
Fix calling function with ident argument
  • Loading branch information
ysugimoto authored Nov 23, 2023
2 parents 91a9228 + b473fdd commit 9bc27b0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion interpreter/expression.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func (i *Interpreter) ProcessFunctionCallExpression(exp *ast.FunctionCallExpress
// This is because some function uses collection value like req.http.Cookie as ID type,
// But the processor passes *value.String as primitive value normally.
// In order to treat collection value inside, ensure ident argument is treated as correspond types.
if ident, ok := exp.Arguments[j].(*ast.Ident); !ok {
if ident, ok := exp.Arguments[j].(*ast.Ident); ok {
args[j] = &value.Ident{Value: ident.Value}
} else {
return value.Null, errors.WithStack(
Expand Down
11 changes: 11 additions & 0 deletions interpreter/expression_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,3 +274,14 @@ sub vcl_recv {
"req.http.Foo": &value.String{Value: "yes"},
})
}

func TestProcessFunctionCallExpressionWithIdent(t *testing.T) {
vcl := `
sub vcl_recv {
set req.http.Foo2 = "yes";
set req.http.Foo = header.get(req, "Foo2");
}`
assertInterpreter(t, vcl, context.RecvScope, map[string]value.Value{
"req.http.Foo": &value.String{Value: "yes"},
})
}

0 comments on commit 9bc27b0

Please sign in to comment.