falco
falco copied to clipboard
[BUG] set statement right side expression evaluation
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
I will tackle to solve this issue.