mono/mono · warning

%s: w - line %d of "%s", the value of %s has been redeclared

Error message

%s: w - line %d of "%s", the value of %s has been redeclared

What it means

Warning (not fatal) in jay: revalued_warning(s) prints '<progname>: w - line <n> of "<file>", the value of <s> has been redeclared'. It does NOT call done(), so jay continues. It fires when the same token's numeric value is assigned more than once via %token (e.g. '%token A 1' and later '%token A 2').

Source

Thrown at mcs/jay/error.c:186

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);
}

void
terminal_start (const char *s)
{
    fprintf(stderr, "%s: e - line %d of \"%s\", the start symbol %s is a \
token\n", myname, lineno, input_file_name, s);
    done(1);
}

void
restarted_warning (void)
{
    fprintf(stderr, "%s: w - line %d of \"%s\", the start symbol has been \
redeclared\n", myname, lineno, input_file_name);
}

View on GitHub (pinned to 0f53e9e151)

Solutions

  1. Locate every %token declaration for the symbol and keep one with a single value.
  2. Remove the duplicate/conflicting %token value line.
  3. If numbering must change, update all references consistently in one pass.

Example fix

// before
%token PLUS '+'
%token PLUS '+'

// after
%token PLUS '+'
Defensive patterns

Strategy: validation

Validate before calling

import re, sys
from collections import defaultdict
src = open(sys.argv[1]).read()
vals = defaultdict(set)
for m in re.finditer(r'%token\s+(?:<[^>]+>\s+)?(\w+)(?:\s+(\d+))?', src):
    if m.group(2):
        vals[m.group(1)].add(m.group(2))
dups = {t: v for t, v in vals.items() if len(v) > 1}
if dups:
    raise SystemExit(f'token value redeclared: {dups}')

Prevention

When it happens

Trigger: Two %token declarations give the same token name different literal integer values, or a generated grammar re-emits a token with a new number.

Common situations: Merging grammars that number tokens differently; regeneration that changed token numbering but left an old declaration; manual edits that duplicated a %token line.

Related errors


AI-assisted analysis of mono/mono@0f53e9e151 (2026-08-13). Data as JSON: /api/errors/b07d06bc6b54cf99. Report an issue: GitHub.