[Varnish] #1579: vcc: conversion to string with + operator incomplete
Varnish
varnish-bugs at varnish-cache.org
Mon Sep 22 16:38:28 CEST 2014
#1579: vcc: conversion to string with + operator incomplete
----------------------+----------------------------------
Reporter: slink | Owner: phk
Type: defect | Status: closed
Priority: normal | Milestone: Varnish 4.0 release
Component: varnishd | Version: trunk
Severity: normal | Resolution: fixed
Keywords: |
----------------------+----------------------------------
Comment (by Lasse Karstensen <lkarsten@…>):
In [7d99e1be1c0b772fb84db18bce12eb69c09a22f1]:
{{{
#!CommitTicketReference repository=""
revision="7d99e1be1c0b772fb84db18bce12eb69c09a22f1"
Rework how we infer types in the VCC expresion evaluator.
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
}}}
--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1579#comment:3>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator
More information about the varnish-bugs
mailing list