[master] e46ae71aa Make VCC not fail if you try to pass STRANDS to STRING_LIST.

Poul-Henning Kamp phk at FreeBSD.org
Fri Jan 4 10:18:05 UTC 2019


commit e46ae71aaf57047b1e50f07fd55f9758c870fa65
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Fri Jan 4 10:15:59 2019 +0000

    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

diff --git a/bin/varnishtest/tests/m00000.vtc b/bin/varnishtest/tests/m00000.vtc
index 355bb3c56..e7f1d4ad1 100644
--- a/bin/varnishtest/tests/m00000.vtc
+++ b/bin/varnishtest/tests/m00000.vtc
@@ -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");
+	}
+}
diff --git a/doc/sphinx/reference/vmod.rst b/doc/sphinx/reference/vmod.rst
index d8cf6e4b0..36ef2b51c 100644
--- a/doc/sphinx/reference/vmod.rst
+++ b/doc/sphinx/reference/vmod.rst
@@ -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
diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c
index b92781047..295b81e14 100644
--- a/lib/libvcc/vcc_expr.c
+++ b/lib/libvcc/vcc_expr.c
@@ -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);
diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc
index e3fb3cf12..5faa718bf 100644
--- a/lib/libvmod_debug/vmod.vcc
+++ b/lib/libvmod_debug/vmod.vcc
@@ -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)
diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c
index 474bc064f..8738ee243 100644
--- a/lib/libvmod_debug/vmod_debug.c
+++ b/lib/libvmod_debug/vmod_debug.c
@@ -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);
+}


More information about the varnish-commit mailing list