Commit 60b5e71e authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Properly complain if people try to reuse symbols.

Fixes #1510
parent 38ee7837
varnishtest "Duplicate object names"
varnish v1 -errvcl {Object name 'first' already used.} {
import ${vmod_debug};
sub vcl_init {
new first = debug.obj("FOO");
new first = debug.obj("BAH");
}
}
varnish v1 -errvcl {Object name 'first' already used.} {
import ${vmod_debug};
backend first { .host = "${bad_ip}"; }
sub vcl_init {
new first = debug.obj("FOO");
}
}
......@@ -164,10 +164,25 @@ parse_new(struct vcc *tl)
return;
}
sy1 = VCC_FindSymbol(tl, tl->t, SYM_NONE);
if (sy1 != NULL) {
VSB_printf(tl->sb, "Object name '%.*s' already used.\n",
PF(tl->t));
VSB_printf(tl->sb, "First usage:\n");
AN(sy1->def_b);
if (sy1->def_e != NULL)
vcc_ErrWhere2(tl, sy1->def_b, sy1->def_e);
else
vcc_ErrWhere(tl, sy1->def_b);
VSB_printf(tl->sb, "Redefinition:\n");
vcc_ErrWhere(tl, tl->t);
return;
}
XXXAZ(sy1);
sy1 = VCC_AddSymbolTok(tl, tl->t, SYM_NONE); // XXX: NONE ?
XXXAN(sy1);
sy1->def_b = tl->t;
vcc_NextToken(tl);
ExpectErr(tl, '=');
......@@ -243,6 +258,7 @@ parse_new(struct vcc *tl)
}
p += 2;
}
sy1->def_e = tl->t;
/*lint -restore */
}
......
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