• 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
v00020.vtc 5.62 KB