• Poul-Henning Kamp's avatar
    Rework how we infer types in the VCC expresion evaluator. · 7d99e1be
    Poul-Henning Kamp authored
    This mainly (only ?) changes things when we ask for an expression
    of type STRING or STTRING_LIST.
    
    Previously addition and subtraction would follow the general rule,
    "first argument determines intial type" and that would make an
    expression like this fail:
    
    	set resp.http.server_port_foo = std.port(server.ip) + "_foo";
    
    Because the addition tries to evaluate  "INT + STRING".
    
    The idea was that people would rewrite this as:
    
    	set resp.http.server_port_foo = "" + std.port(server.ip) + "_foo";
    
    To make the first argument STRING and everything will then just work.
    
    However, this is needlessly strict in the case where we are actively
    desiring the expression to evaluate to STRING -- like above where
    resp.http.* has type STRING.
    
    With the new code, when an impossible addition is encountered, it
    will look at the type requested of the expression, and if it is
    STRING, convert the current subexpression to STRING and continue
    adding.
    
    A large number of subtests which are designed to fail started working
    with this change, they have been fixed by not using *.http.* variables
    as scaffolding..
    
    You can still get into some weird corner-cases like the difference
    between:
    
    	set resp.http.foobar = req.ttl + 1s + "_" + req.ttl + 1s;
    and
    	set resp.http.foobar = req.ttl + 1s + "_" + req.ttl + 1;
    and
    	set resp.http.foobar = req.ttl + 1s + "_" + (req.ttl + 1s);
    
    (Hint: The last one is the only one which does what you think)
    
    Fixes #1579
    7d99e1be
Name
Last commit
Last update
bin Loading commit data...
doc Loading commit data...
etc Loading commit data...
include Loading commit data...
lib Loading commit data...
m4 Loading commit data...
man Loading commit data...
redhat Loading commit data...
.gitignore Loading commit data...
.travis.yml Loading commit data...
CONTRIBUTING Loading commit data...
ChangeLog Loading commit data...
INSTALL Loading commit data...
LICENSE Loading commit data...
Makefile.am Loading commit data...
Makefile.inc.phk Loading commit data...
Makefile.phk Loading commit data...
README Loading commit data...
autogen.des Loading commit data...
autogen.sh Loading commit data...
config.phk Loading commit data...
configure.ac Loading commit data...
flint.lnt Loading commit data...
varnish.m4 Loading commit data...
varnishapi-uninstalled.pc.in Loading commit data...
varnishapi.pc.in Loading commit data...