[6.0] 33b6d4e81 Improve function call argument error messages.

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Thu Jun 27 17:05:10 UTC 2019


commit 33b6d4e817eef0992afff2df380acd99b2469bb5
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu Jan 3 12:40:05 2019 +0000

    Improve function call argument error messages.
    
    Fixes: #2874

diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c
index 780befa0c..b92781047 100644
--- a/lib/libvcc/vcc_expr.c
+++ b/lib/libvcc/vcc_expr.c
@@ -576,6 +576,10 @@ vcc_func(struct vcc *tl, struct expr **e, const void *priv,
 				break;
 		}
 		vcc_do_arg(tl, fa);
+		if (tl->err)
+			VSB_printf(tl->sb, "Expected argument: %s %s\n\n",
+			    fa->type->name,
+			    fa->name ? fa->name : "(unnamed argument)");
 		ERRCHK(tl);
 		if (tl->t->tok == ')')
 			break;
@@ -666,6 +670,8 @@ vcc_Eval_Func(struct vcc *tl, const struct vjsn_val *spec,
 	struct expr *e = NULL;
 
 	vcc_func(tl, &e, spec, extra, sym);
+	if (tl->err)
+		VSB_printf(tl->sb, "While compiling function call:\n");
 	ERRCHK(tl);
 	vcc_expr_fmt(tl->fb, tl->indent, e);
 	VSB_cat(tl->fb, ";\n");
@@ -752,6 +758,11 @@ vcc_expr4(struct vcc *tl, struct expr **e, vcc_type_t fmt)
 			AN(sym->eval);
 			AZ(*e);
 			sym->eval(tl, e, t, sym, fmt);
+			if (tl->err) {
+				VSB_printf(tl->sb,
+				    "While compiling function call:\n\n");
+				vcc_ErrWhere2(tl, t, tl->t);
+			}
 			ERRCHK(tl);
 			/* Unless asked for a HEADER, fold to string here */
 			if (*e && fmt != HEADER && (*e)->fmt == HEADER) {
@@ -1372,6 +1383,7 @@ vcc_Act_Call(struct vcc *tl, struct token *t, struct symbol *sym)
 		SkipToken(tl, ';');
 		VSB_cat(tl->fb, ";\n");
 	} else if (t != tl->t) {
+		VSB_printf(tl->sb, "While compiling function call:\n\n");
 		vcc_ErrWhere2(tl, t, tl->t);
 	}
 	vcc_delete_expr(e);


More information about the varnish-commit mailing list