[master] 5a974c753 vcc: teach VCC_SymbolGet() how to be a good partner for life

Nils Goroll nils.goroll at uplex.de
Tue Feb 2 17:33:06 UTC 2021


commit 5a974c7537890de8f2542c1f1f66c5d3230eaf36
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Tue Feb 2 18:10:21 2021 +0100

    vcc: teach VCC_SymbolGet() how to be a good partner for life
    
    In any good relationship, one should be clear about expectations. And
    VCL authors want to know what VCC wants to hear, so tell them.
    
    ;)

diff --git a/bin/varnishtest/tests/m00008.vtc b/bin/varnishtest/tests/m00008.vtc
index 95ea39af0..1d1696784 100644
--- a/bin/varnishtest/tests/m00008.vtc
+++ b/bin/varnishtest/tests/m00008.vtc
@@ -2,7 +2,7 @@ varnishtest "VCL compiler vmod coverage / vmod loading"
 
 feature topbuild
 
-varnish v1 -errvcl {Symbol 'debug' has wrong type (sub):} {
+varnish v1 -errvcl {Symbol 'debug' has wrong type (sub), expected vmod:} {
 	backend b { .host = "${localhost}"; }
 	sub debug {}
 	import debug;
diff --git a/bin/varnishtest/tests/v00018.vtc b/bin/varnishtest/tests/v00018.vtc
index 7e8b2b827..7e515e967 100644
--- a/bin/varnishtest/tests/v00018.vtc
+++ b/bin/varnishtest/tests/v00018.vtc
@@ -122,7 +122,7 @@ varnish v1 -errvcl {Not a valid action in subroutine 'vcl_recv'} {
 	}
 }
 
-varnish v1 -errvcl {Symbol 'vcl_recv' has wrong type (sub):} {
+varnish v1 -errvcl {Symbol 'vcl_recv' has wrong type (sub), expected vcl:} {
 	sub vcl_recv {
 		return (vcl(vcl_recv));
 	}
diff --git a/bin/varnishtest/tests/v00020.vtc b/bin/varnishtest/tests/v00020.vtc
index 45f9474cd..068135836 100644
--- a/bin/varnishtest/tests/v00020.vtc
+++ b/bin/varnishtest/tests/v00020.vtc
@@ -360,7 +360,7 @@ varnish v1 -errvcl {'||' must be preceeded by BOOL, found REAL.} {
 	sub vcl_recv { if (std.random(0,1) || 0) { } }
 }
 
-varnish v1 -errvcl {Symbol 'acl' has wrong type (reserved):} {
+varnish v1 -errvcl {Symbol 'acl' has wrong type (reserved), expected sub:} {
 	import std;
 	sub vcl_recv { call acl; }
 }
diff --git a/bin/varnishtest/tests/v00021.vtc b/bin/varnishtest/tests/v00021.vtc
index 4c8e8ee26..720ff8ca5 100644
--- a/bin/varnishtest/tests/v00021.vtc
+++ b/bin/varnishtest/tests/v00021.vtc
@@ -149,7 +149,7 @@ varnish v1 -errvcl {Symbol not found: 'req.foobar'} {
 	sub vcl_recv { set req.foobar = 3; }
 }
 
-varnish v1 -errvcl {Symbol 'anacl' has wrong type (acl):} {
+varnish v1 -errvcl {Symbol 'anacl' has wrong type (acl), expected sub:} {
 	sub vcl_recv {
 		if (client.ip ~ anacl) { }
 	}
@@ -162,7 +162,7 @@ varnish v1 -errvcl {Symbols named 'vcl_*' are reserved.} {
 	}
 }
 
-varnish v1 -errvcl {Symbol 'true' has wrong type (func):} {
+varnish v1 -errvcl {Symbol 'true' has wrong type (func), expected acl:} {
 	sub vcl_recv {
 		if (client.ip ~ true) { }
 	}
diff --git a/lib/libvcc/vcc_symb.c b/lib/libvcc/vcc_symb.c
index 96cce270f..0138c2cf6 100644
--- a/lib/libvcc/vcc_symb.c
+++ b/lib/libvcc/vcc_symb.c
@@ -338,7 +338,8 @@ VCC_SymbolGet(struct vcc *tl, vcc_ns_t ns, vcc_kind_t kind,
 		VSB_cat(tl->sb, "Symbol '");
 		for (tn1 = t0; tn1 != tl->t; tn1 = VTAILQ_NEXT(tn1, list))
 			VSB_printf(tl->sb, "%.*s", PF(tn1));
-		VSB_printf(tl->sb, "' has wrong type (%s): ", sym->kind->name);
+		VSB_printf(tl->sb, "' has wrong type (%s), expected %s:",
+		    sym->kind->name, kind->name);
 		VSB_cat(tl->sb, "\nAt: ");
 		vcc_ErrWhere2(tl, t0, tl->t);
 		if (sym->def_b != NULL) {


More information about the varnish-commit mailing list