Permalink
Browse files

Make VCC not fail if you try to pass STRANDS to STRING_LIST.

Strenghen the case against STRING_LIST in the docs.

See also: #2873
  • Loading branch information...
bsdphk committed Jan 4, 2019
1 parent 032db57 commit e46ae71aaf57047b1e50f07fd55f9758c870fa65
@@ -120,3 +120,10 @@ varnish v1 -errvcl {Expression has type STRING, expected REAL} {
set resp.http.who = std.random("foo", "bar");
}
}

varnish v1 -errvcl {Cannot convert type STRING(STRANDS) to STRING(STRING_LIST)} {
import debug;
sub vcl_deliver {
set resp.http.who = debug.return_strands(req.url + "bar");
}
}
@@ -394,9 +394,8 @@ STEVEDORE
STRING_LIST
C-type: ``const char *, ...``

`Notice: New vmod developments for 6.1 and higher should
consider STRANDS as a better alternative to STRING_LIST, which
will eventually be replaced entirely.`
`Notice: New vmod developments for 6.1 and later must
use STRANDS instead of STRING_LIST, which is going away.`

A multi-component text-string. We try very hard to avoid
doing text-processing in Varnish, and this is one way we
@@ -1311,7 +1311,14 @@ vcc_expr0(struct vcc *tl, struct expr **e, vcc_type_t fmt)
else
vcc_expr_cor(tl, e, fmt);
ERRCHK(tl);
assert(!(*e)->fmt->stringform);

if ((*e)->fmt->stringform) {
VSB_printf(tl->sb, "Cannot convert type %s(%s) to %s(%s)\n",
vcc_utype((*e)->fmt), (*e)->fmt->name,
vcc_utype(fmt), fmt->name);
vcc_ErrWhere2(tl, t1, tl->t);
return;
}

if ((*e)->fmt != STRINGS && fmt->stringform)
vcc_expr_tostring(tl, e, STRINGS);
@@ -227,3 +227,5 @@ $Method STRING .meth_opt(PRIV_CALL, PRIV_VCL, PRIV_TASK,
[STRING s], [BOOL b])

Test object method with all the fancy stuff.

$Function STRANDS return_strands(STRANDS strand)
@@ -599,3 +599,11 @@ xyzzy_priv_perf(VRT_CTX, VCL_INT size, VCL_INT rounds)

return (d);
}

VCL_STRANDS
xyzzy_return_strands(VRT_CTX, VCL_STRANDS strand)
{

CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
return (strand);
}

0 comments on commit e46ae71

Please sign in to comment.