Commit a80f4ef9 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Unify bespoke error messages to "Symbol not found" before things

get too confusing.
parent c3610d36
varnishtest "Test VCC errors out if probe is used before it is defined"
varnish v1 -errvcl "Probe not found: 'p'" {
varnish v1 -errvcl "Symbol not found: 'p'" {
backend b {
.host = "127.0.0.1";
.probe = p;
......
......@@ -133,7 +133,7 @@ varnish v1 -errvcl {Symbol 'vcl_recv' has wrong type (sub):} {
}
}
varnish v1 -syntax 4.0 -errvcl {Not a VCL label:} {
varnish v1 -syntax 4.0 -errvcl {Symbol not found:} {
sub vcl_recv {
return (vcl(vcl_recv));
}
......
......@@ -64,7 +64,7 @@ varnish v1 -errvcl {Comparison of different types: STRING '==' INT} {
}
}
varnish v1 -errvcl {Unknown variable: 'req.http.req.http.foo'} {
varnish v1 -errvcl {Symbol not found: 'req.http.req.http.foo'} {
backend b { .host = "127.0.0.1"; }
sub vcl_recv {
set req.http.req.http.foo = "bar";
......
......@@ -91,7 +91,7 @@ varnish v1 -vcl {
}
}
varnish v1 -errvcl {Unknown variable: 'req.foobar'} {
varnish v1 -errvcl {Symbol not found: 'req.foobar'} {
backend foo { .host = "127.0.0.1"; }
sub vcl_recv { set req.foobar = 3; }
}
......
......@@ -94,7 +94,7 @@ vcc_act_set(struct vcc *tl, struct token *t, struct symbol *sym)
(void)t;
ExpectErr(tl, ID);
t = tl->t;
sym = VCC_SymbolGet(tl, SYM_VAR, "Unknown variable", XREF_NONE);
sym = VCC_SymbolGet(tl, SYM_VAR, SYMTAB_EXISTING, XREF_NONE);
ERRCHK(tl);
AN(sym);
if (sym->w_methods == 0) {
......@@ -146,7 +146,7 @@ vcc_act_unset(struct vcc *tl, struct token *t, struct symbol *sym)
/* XXX: Wrong, should use VCC_Expr(HEADER) */
ExpectErr(tl, ID);
t = tl->t;
sym = VCC_SymbolGet(tl, SYM_VAR, "Unknown variable", XREF_NONE);
sym = VCC_SymbolGet(tl, SYM_VAR, SYMTAB_EXISTING, XREF_NONE);
ERRCHK(tl);
AN(sym);
if (sym->u_methods == 0) {
......@@ -269,7 +269,7 @@ vcc_act_return_vcl(struct vcc *tl)
ExpectErr(tl, '(');
vcc_NextToken(tl);
ExpectErr(tl, ID);
sym = VCC_SymbolGet(tl, SYM_VCL, "Not a VCL label", XREF_NONE);
sym = VCC_SymbolGet(tl, SYM_VCL, SYMTAB_EXISTING, XREF_NONE);
ERRCHK(tl);
AN(sym);
if (sym->eval_priv == NULL) {
......
......@@ -432,7 +432,7 @@ vcc_ParseHostDef(struct vcc *tl, const struct token *t_be, const char *vgcname)
(void)vcc_default_probe(tl);
} else {
pb = VCC_SymbolGet(tl, SYM_PROBE,
"Probe not found", XREF_REF);
SYMTAB_EXISTING, XREF_REF);
ERRCHK(tl);
AN(pb);
Fb(tl, 0, "\t.probe = %s,\n", pb->rname);
......@@ -540,6 +540,7 @@ vcc_ParseBackend(struct vcc *tl)
} else {
sym = VCC_HandleSymbol(tl, BACKEND, "vgc_backend");
ERRCHK(tl);
AN(sym);
dn = sym->rname;
if (tl->default_director == NULL) {
tl->first_director = sym;
......
......@@ -350,13 +350,19 @@ void vcc_stevedore(struct vcc *vcc, const char *stv_name);
/* vcc_symb.c */
void VCC_PrintCName(struct vsb *vsb, const char *b, const char *e);
struct symbol *VCC_MkSym(struct vcc *tl, const char *b, vcc_kind_t, int, int);
extern const char XREF_NONE[];
extern const char XREF_DEF[];
extern const char XREF_REF[];
extern const char SYMTAB_NOERR[];
extern const char SYMTAB_CREATE[];
struct symbol *VCC_SymbolGet(struct vcc *, vcc_kind_t, const char *,
const char *);
struct symxref { const char *name; };
extern const struct symxref XREF_NONE[1];
extern const struct symxref XREF_DEF[1];
extern const struct symxref XREF_REF[1];
struct symmode { const char *name; };
extern const struct symmode SYMTAB_NOERR[1];
extern const struct symmode SYMTAB_CREATE[1];
extern const struct symmode SYMTAB_EXISTING[1];
struct symbol *VCC_SymbolGet(struct vcc *, vcc_kind_t,
const struct symmode *, const struct symxref *);
typedef void symwalk_f(struct vcc *tl, const struct symbol *s);
void VCC_WalkSymbols(struct vcc *tl, symwalk_f *func, vcc_kind_t);
......
......@@ -688,8 +688,7 @@ vcc_expr4(struct vcc *tl, struct expr **e, vcc_type_t fmt)
switch (tl->t->tok) {
case ID:
t = tl->t;
sym = VCC_SymbolGet(tl, SYM_NONE, "Symbol not found",
XREF_REF);
sym = VCC_SymbolGet(tl, SYM_NONE, SYMTAB_EXISTING, XREF_REF);
ERRCHK(tl);
AN(sym);
if (sym->kind == SYM_FUNC && sym->type == VOID) {
......
......@@ -226,19 +226,25 @@ vcc_sym_in_tab(struct vcc *tl, struct symtab *st,
}
const char XREF_NONE[] = "xref_none";
const char XREF_DEF[] = "xref_def";
const char XREF_REF[] = "xref_ref";
const char SYMTAB_NOERR[] = "sym_noerror";
const char SYMTAB_CREATE[] = "sym_create";
const struct symxref XREF_NONE[1] = {{"xref_none"}};
const struct symxref XREF_DEF[1] = {{"xref_def"}};
const struct symxref XREF_REF[1] = {{"xref_ref"}};
const struct symmode SYMTAB_NOERR[1] = {{"sym_noerror"}};
const struct symmode SYMTAB_CREATE[1] = {{"sym_create"}};
const struct symmode SYMTAB_EXISTING[1] = {{"Symbol not found"}};
struct symbol *
VCC_SymbolGet(struct vcc *tl, vcc_kind_t kind, const char *e, const char *x)
VCC_SymbolGet(struct vcc *tl, vcc_kind_t kind,
const struct symmode *e, const struct symxref *x)
{
struct symtab *st;
struct symbol *sym;
struct token *t0, *tn, *tn1;
AN(tl);
AN(e);
AN(x);
AN(x->name);
if (tl->syntax >= VCL_41 && e == SYMTAB_CREATE && kind != SYM_SUB &&
(tl->t->b[0] == 'v'|| tl->t->b[0] == 'V') &&
(tl->t->b[1] == 'c'|| tl->t->b[1] == 'C') &&
......@@ -270,7 +276,7 @@ VCC_SymbolGet(struct vcc *tl, vcc_kind_t kind, const char *e, const char *x)
return (sym);
tl->t = VTAILQ_NEXT(tn, list);
if (sym == NULL) {
VSB_printf(tl->sb, "%s: '", e);
VSB_printf(tl->sb, "%s: '", e->name);
for (tn1 = t0; tn1 != tl->t; tn1 = VTAILQ_NEXT(tn1, list))
VSB_printf(tl->sb, "%.*s", PF(tn1));
VSB_printf(tl->sb, "'");
......
......@@ -402,7 +402,7 @@ vcc_Act_New(struct vcc *tl, struct token *t, struct symbol *sym)
ExpectErr(tl, ID);
t = tl->t;
sy2 = VCC_SymbolGet(tl, SYM_OBJECT, "Symbol not found", XREF_NONE);
sy2 = VCC_SymbolGet(tl, SYM_OBJECT, SYMTAB_EXISTING, XREF_NONE);
ERRCHK(tl);
AN(sy2);
if (sy2->eval_priv == NULL) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment