oracle/graal · error · RuleParseError

Too many arguments to ${descriptor.nodeType.nodeClass}

Error message

Too many arguments to ${descriptor.nodeType.nodeClass}

What it means

Thrown by RuleParser.parseExpression when the pattern inside parentheses has already filled every declared input of the node type but another token remains before the expected ')'. The parser fills exactly nodeType.inputs.size() slots, then requires the next token to be ')'; anything else is 'too many arguments'.

Source

Thrown at compiler/src/jdk.graal.compiler.processor/src/jdk/graal/compiler/core/match/processor/MatchProcessor.java:176

                next();
                MatchDescriptor descriptor = parseType(true);
                for (int n = 0; n < descriptor.nodeType.inputs.size(); n++) {
                    if (peek("(").equals("(")) {
                        descriptor.inputs[n] = parseExpression();
                    } else {
                        descriptor.inputs[n] = parseType(false);
                    }
                }
                for (int n = 0; n < descriptor.nodeType.inputs.size(); n++) {
                    if (descriptor.inputs[n] == null) {
                        throw new RuleParseError("not enough inputs for " + descriptor.name);
                    }
                }
                if (peek(")").equals(")")) {
                    next();
                    return descriptor;
                }
                throw new RuleParseError("Too many arguments to " + descriptor.nodeType.nodeClass);
            }
            throw new RuleParseError("Extra tokens following match pattern: " + peek(null));
        }

        private MatchDescriptor parseType(boolean forExpression) {
            TypeDescriptor type = null;
            String name = null;
            if (Character.isUpperCase(peek("node type or name").charAt(0))) {
                String token = next();
                type = knownTypes.get(token);
                if (type == null) {
                    throw new RuleParseError("Unknown node type: " + token);
                }
                if (peek("=").equals("=")) {
                    next();
                    name = next();
                }
                originatingElements.addAll(type.originatingElements);

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Count the arguments in the rule against the node class's declared inputs and delete the extras.
  2. If you intended the extra element as a condition, move it into the match method's Java body, not the pattern.
  3. Regenerate/re-read the node's input list after any @MatchableNode change and reconcile all rules.

Example fix

// before (Add has 2 inputs)
@MatchRule("Add(x, y, z)")

// after
@MatchRule("Add(x, y)")
Defensive patterns

Strategy: try-catch

Try / catch

Compile-time only; no catch site. Treat 'Too many arguments to <NodeClass>' in build output as an arity mismatch to fix in the @MatchRule string.

Prevention

When it happens

Trigger: Writing @MatchRule("Add(x, y, z)") for a two-input node, or adding an extra captured name, constant pattern, or stray token after the last input. The offending extra is whatever precedes the missing ')'.

Common situations: Node refactorings that removed an input while old rules still pass three arguments; misunderstanding that trailing options/labels are not part of the DSL; duplicating an input while hand-editing.

Related errors


AI-assisted analysis of oracle/graal@a66e9ccd1d (2026-08-14). Data as JSON: /api/errors/be975a559924a081. Report an issue: GitHub.