[master] 46a6a3af6 Apply bandaid to missing VMOD symbol errors

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Fri Nov 8 18:36:07 UTC 2019


commit 46a6a3af681644f43e2e813ee68f8bd53b4cd1bb
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Fri Nov 8 19:10:48 2019 +0100

    Apply bandaid to missing VMOD symbol errors
    
    The VCL compilation error message when a VMOD symbol does not exist
    simply disappeared. When I figured how to bring it back I was lucky
    my test case exhibited another quirk for the following case:
    
        new foo = bar.foo()
    
    Where bar is a successfully imported VMOD, and foo is the missing
    constructor. For some reason instance symbols are created with VCL
    low and high values, so the missing foo constructor ended up being
    confused with the existing foo instance.
    
    The regression I initially hunted down (the lack of error message
    in the first place) was introduced by 340abd0456e4. I suggest we
    don't give VMOD-induced symbols a VCL low/high since by definition
    they are not tied to a VCL version (even though they may do so at
    run time) and use that criteria to filter out the spurious error
    message:
    
    > Symbol not found: 'directors.foo' (Only available when 4.0 <= VCL
    > syntax <= 4.0)
    
    If there is no proper low or high (and 4.0 is legit) then we don't
    print the "Only available when" part? For now I needed the bandaid.
    
    Refs 340abd0456e4d018fd1589f406287057ab6740ff

diff --git a/bin/varnishtest/tests/v00016.vtc b/bin/varnishtest/tests/v00016.vtc
index 56ba92c4f..f1cab3db6 100644
--- a/bin/varnishtest/tests/v00016.vtc
+++ b/bin/varnishtest/tests/v00016.vtc
@@ -117,6 +117,19 @@ varnish v1 -syntax 4.0 -errvcl {Undefined acl foo} {
 	}
 }
 
+# NB: The line break in -errvcl is here on purpose, it prevents
+# a spurious "Only available when" addition to be missed when the
+# foo constructor could be confused with the foo instance name.
+varnish v1 -syntax 4.0 -errvcl {Symbol not found: 'directors.foo'
+At:} {
+	import directors;
+	backend b { .host = "127.0.0.1"; }
+
+	sub vcl_init {
+		new foo = directors.foo();
+	}
+}
+
 # 'foo' overloaded
 varnish v1 -syntax 4.0 -errvcl {Symbol not found: 'foo'} {
 	backend b { .host = "127.0.0.1"; }
diff --git a/lib/libvcc/vcc_symb.c b/lib/libvcc/vcc_symb.c
index 4d1a4ee72..3ef753220 100644
--- a/lib/libvcc/vcc_symb.c
+++ b/lib/libvcc/vcc_symb.c
@@ -275,6 +275,8 @@ VCC_SymbolGet(struct vcc *tl, vcc_kind_t kind,
 			break;
 		tn = tn1;
 	}
+	if (sym != NULL && sym->kind == SYM_VMOD && e == SYMTAB_PARTIAL)
+		e = SYMTAB_EXISTING;
 	if (sym != NULL && e == SYMTAB_PARTIAL) {
 		st = st2;
 		tn = tn2;
@@ -294,7 +296,8 @@ VCC_SymbolGet(struct vcc *tl, vcc_kind_t kind,
 			VSB_printf(tl->sb, "%.*s", PF(tn1));
 		VSB_cat(tl->sb, "'");
 		sym = vcc_sym_in_tab(tl, st, kind, VCL_LOW, VCL_HIGH);
-		if (sym != NULL) {
+		if (sym != NULL && sym->kind != SYM_OBJECT &&
+		    sym->kind != SYM_INSTANCE) { /* XXX: too specific */
 			VSB_cat(tl->sb, " (Only available when");
 			if (sym->lorev >= VCL_LOW)
 				VSB_printf(tl->sb, " %.1f <=", .1 * sym->lorev);


More information about the varnish-commit mailing list