falco icon indicating copy to clipboard operation
falco copied to clipboard

[BUG] set statement right side expression evaluation

Open richardmarshall opened this issue 1 year ago • 1 comments

Please fill all required sections

Kind of proposals

required You can turn on multiple checkboxes.

  • [] Parser
  • [x] Linter
  • [x] Simulator
  • [x] Testing

Describe the problem

Both the interpreter and linter are evaluating the right side of a set statement before performing type checking. In some cases this is accepting expressions that Fastly will reject.

For example assigning a conditional expression to a string variable is not valid but passes the type checking because the resulting bool value can be coerced to a string during assignment.

VCL code that cause the problem / reproduceable

The following VCL passes linting and will not cause an error in the interpreter.

set req.http.foo = (req.http.bar == "baz");

Expected behavior

Linter / interpreter should report an error.

Fiddle showing Fastly error for this case: https://fiddle.fastly.dev/fiddle/b05aaad8

richardmarshall avatar Feb 28 '24 19:02 richardmarshall

I will tackle to solve this issue.

ysugimoto avatar Apr 05 '24 08:04 ysugimoto