[master] f479083 Better error on missing import

Federico G. Schwindt fgsch at lodoss.net
Mon Mar 3 17:03:17 CET 2014


commit f47908316d9ff23fdc2a438f68e92d27bd194853
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date:   Mon Mar 3 16:01:56 2014 +0000

    Better error on missing import
    
    Fixes: #1436

diff --git a/bin/varnishtest/tests/v00016.vtc b/bin/varnishtest/tests/v00016.vtc
index 69e99e5..b23d21e 100644
--- a/bin/varnishtest/tests/v00016.vtc
+++ b/bin/varnishtest/tests/v00016.vtc
@@ -98,3 +98,9 @@ varnish v1 -vcl {
 	backend b { .host = "127.0.0.1"; }
 	sub vcl_hash { if (2 == 3) { } }
 }
+
+varnish v1 -errvcl {Object not found: 'foo.bar'} {
+	sub vcl_init {
+		new bar = foo.bar();
+	}
+}
diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c
index b0f7d98..35f88f8 100644
--- a/lib/libvcc/vcc_action.c
+++ b/lib/libvcc/vcc_action.c
@@ -190,6 +190,13 @@ parse_new(struct vcc *tl)
 
 	ExpectErr(tl, ID);
 	sy2 = VCC_FindSymbol(tl, tl->t, SYM_OBJECT);
+	if (sy2 == NULL) {
+		VSB_printf(tl->sb, "Object not found: ");
+		vcc_ErrToken(tl, tl->t);
+		VSB_printf(tl->sb, " at ");
+		vcc_ErrWhere(tl, tl->t);
+		return;
+	}
 	XXXAN(sy2);
 
 	/*lint -save -e448 */



More information about the varnish-commit mailing list