{"record":{"id":"86008884dc6ac261","repo":"mono/mono","slug":"s-w-line-d-of-s-the-type-of-s-has-been-r","errorCode":null,"errorMessage":"%s: w - line %d of \"%s\", the type of %s has been redeclared\n","messagePattern":"(.+?): w - line (.+?) of \"(.+?)\", the type of (.+?) has been redeclared\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"mcs/jay/error.c","lineNumber":172,"sourceCode":"used_reserved (const char *s)\n{\n    fprintf(stderr, \"%s: e - line %d of \\\"%s\\\", illegal use of reserved symbol \\\n%s\\n\", myname, lineno, input_file_name, s);\n    done(1);\n}\n\nvoid\ntokenized_start (const char *s)\n{\n     fprintf(stderr, \"%s: e - line %d of \\\"%s\\\", the start symbol %s cannot be \\\ndeclared to be a token\\n\", myname, lineno, input_file_name, s);\n     done(1);\n}\n\nvoid\nretyped_warning (const char *s)\n{\n    fprintf(stderr, \"%s: w - line %d of \\\"%s\\\", the type of %s has been \\\nredeclared\\n\", myname, lineno, input_file_name, s);\n}\n\nvoid\nreprec_warning (const char *s)\n{\n    fprintf(stderr, \"%s: w - line %d of \\\"%s\\\", the precedence of %s has been \\\nredeclared\\n\", myname, lineno, input_file_name, s);\n}\n\nvoid\nrevalued_warning (const char *s)\n{\n    fprintf(stderr, \"%s: w - line %d of \\\"%s\\\", the value of %s has been \\\nredeclared\\n\", myname, lineno, input_file_name, s);\n}\n\nvoid","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/mono/mono/blob/0f53e9e151d92944cacab3e24ac359410c606df6/mcs/jay/error.c#L154-L190","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n%type <int> expr\n%type <str> expr\n\n// after\n%type <int> expr","handlingStrategy":"validation","validationCode":"import re, sys\nfrom collections import defaultdict\nsrc = open(sys.argv[1]).read()\ntypes = defaultdict(set)\nfor m in re.finditer(r'%type\\s+<([^>]+)>\\s+(\\w+)', src):\n    types[m.group(2)].add(m.group(1))\nfor m in re.finditer(r'%token\\s+<([^>]+)>\\s+(\\w+)', src):\n    types[m.group(2)].add(m.group(1))\nconflicts = {s: ts for s, ts in types.items() if len(ts) > 1}\nif conflicts:\n    raise SystemExit(f'type redeclared: {conflicts}')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["jay","parser-generator","warning","type-tag","grammar"],"backgroundTag":null,"analyzedSha":"0f53e9e151d92944cacab3e24ac359410c606df6","analyzedAt":"2026-08-13T18:54:37.190Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}