mono/mono · warning
%s: w - line %d of "%s", the default action assigns an undef
Error message
%s: w - line %d of "%s", the default action assigns an undefined value to $$
What it means
Emitted by default_action_warning() in mcs/jay/error.c:280, reached from end_rule() (reader.c:978) when a rule's LHS has a declared tag, the rule has no explicit action, and the first RHS symbol's tag is null or differs from the LHS tag. jay's implicit default action is `$$ = $1`; when the types mismatch that assignment is undefined, hence the warning (no done()).
Source
Thrown at mcs/jay/error.c:280
untyped_rhs (int i, const char *s)
{
fprintf(stderr, "%s: w - line %d of \"%s\", $%d (%s) is untyped\n",
myname, lineno, input_file_name, i, s);
/** done(1); */
}
void
unknown_rhs (int i)
{
fprintf(stderr, "%s: e - line %d of \"%s\", $%d is untyped\n",
myname, lineno, input_file_name, i);
done(1);
}
void
default_action_warning (void)
{
fprintf(stderr, "%s: w - line %d of \"%s\", the default action assigns an \
undefined value to $$\n", myname, lineno, input_file_name);
}
void
undefined_goal (const char *s)
{
fprintf(stderr, "%s: e - the start symbol %s is undefined\n", myname, s);
done(1);
}
void
undefined_symbol_warning (const char *s)
{
fprintf(stderr, "%s: w - the symbol %s is undefined\n", myname, s);
}
View on GitHub (pinned to 0f53e9e151)
Solutions
- Add an explicit action that assigns the correct value to `$$`, e.g. `{ $$ = $2; }`.
- Align the first RHS symbol's %type tag with the LHS tag if the default `$$ = $1` is intended.
- If the LHS truly needs no value, remove its %type declaration.
Example fix
// before
%type <int> expr
%%
expr : '(' expr ')' ; /* default $$ = $1 where $1 is '(' literal -> default_action_warning */
// after
expr : '(' expr ')' { $$ = $2; } Defensive patterns
Strategy: validation
Prevention
- Give an explicit action `{ $$ = $k; }` to any typed-LHS rule, rather than relying on the default.
- If using the default, ensure the first RHS symbol's %type tag matches the LHS tag.
- Watch literal-token-first productions like `'(' x ')'`, which need `{ $$ = $2; }`.
When it happens
Trigger: A production with a typed LHS but no `{ ... }` action, where the first RHS symbol is either untyped or typed differently.
Common situations: Writing a shorthand production `expr : '(' expr ')' ;` intending `$$ = $2` but relying on the default `$$ = $1`; omitting an action on a rule whose LHS expects a specific type.
Related errors
- %s: w - line %d of "%s", $$ is untyped
- %s: w - line %d of "%s", $%d (%s) is untyped
- %s: e - line %d of "%s", unterminated action
- %s: w - line %d of "%s", $%d references beyond the end of th
- %s: e - line %d of "%s", illegal $-name
AI-assisted analysis of mono/mono@0f53e9e151 (2026-08-13).
Data as JSON: /api/errors/38821c764516116d.
Report an issue: GitHub.