mono/mono · warning
%s: w - line %d of "%s", the type of %s has been redeclared
Error message
%s: w - line %d of "%s", the type of %s has been redeclared
What it means
Warning (not fatal) in jay: retyped_warning(s) prints '<progname>: w - line <n> of "<file>", the type of <s> has been redeclared'. Unlike the error routines it does NOT call done(), so jay continues. It fires when a symbol's semantic '<type>' is declared more than once (via %token/%type/%union) inconsistently.
Source
Thrown at mcs/jay/error.c:172
used_reserved (const char *s)
{
fprintf(stderr, "%s: e - line %d of \"%s\", illegal use of reserved symbol \
%s\n", myname, lineno, input_file_name, s);
done(1);
}
void
tokenized_start (const char *s)
{
fprintf(stderr, "%s: e - line %d of \"%s\", the start symbol %s cannot be \
declared to be a token\n", myname, lineno, input_file_name, s);
done(1);
}
void
retyped_warning (const char *s)
{
fprintf(stderr, "%s: w - line %d of \"%s\", the type of %s has been \
redeclared\n", myname, lineno, input_file_name, s);
}
void
reprec_warning (const char *s)
{
fprintf(stderr, "%s: w - line %d of \"%s\", the precedence of %s has been \
redeclared\n", myname, lineno, input_file_name, s);
}
void
revalued_warning (const char *s)
{
fprintf(stderr, "%s: w - line %d of \"%s\", the value of %s has been \
redeclared\n", myname, lineno, input_file_name, s);
}
voidView on GitHub (pinned to 0f53e9e151)
Solutions
- Search for all declarations of the named symbol and keep a single consistent '<type>'.
- Decide on one type for the symbol and delete the conflicting declaration.
- Treat the warning as a real bug — a mismatched type corrupts $-value access in actions.
Example fix
// before %type <int> expr %type <str> expr // after %type <int> expr
Defensive patterns
Strategy: validation
Validate before calling
import re, sys
from collections import defaultdict
src = open(sys.argv[1]).read()
types = defaultdict(set)
for m in re.finditer(r'%type\s+<([^>]+)>\s+(\w+)', src):
types[m.group(2)].add(m.group(1))
for m in re.finditer(r'%token\s+<([^>]+)>\s+(\w+)', src):
types[m.group(2)].add(m.group(1))
conflicts = {s: ts for s, ts in types.items() if len(ts) > 1}
if conflicts:
raise SystemExit(f'type redeclared: {conflicts}') Prevention
- Declare each symbol's '<type>' exactly once.
- After merging grammar fragments, dedupe %type/%token tag lines.
- Treat the warning as a correctness bug: a wrong type breaks $-value access in actions.
When it happens
Trigger: Two declarations give the same symbol different '<type>' tags, e.g. '%token <int> X' and later '%type <str> X', or repeated %type lines with differing types.
Common situations: Merging grammar fragments that each declare the same token's type; refactoring that left an old %type line behind; generated grammar emitting duplicate type info.
Related errors
- %s: e - line %d of "%s", illegal tag
- %s: w - line %d of "%s", the precedence of %s has been redec
- %s: w - line %d of "%s", the value of %s has been redeclared
- %s: e - line %d of "%s", unexpected end-of-file
- %s: e - line %d of "%s", syntax error
AI-assisted analysis of mono/mono@0f53e9e151 (2026-08-13).
Data as JSON: /api/errors/86008884dc6ac261.
Report an issue: GitHub.