golang/go · error
clause %q: unknown adjustment
Error message
clause %q: unknown adjustment
What it means
Returned by parseScoreAdj when the first element of a clause is not a recognized scoreAdjustTyp name. adjStringToVal walks the bit-flag enum and matches by its String() method; if no enum value's name equals elems[0], the adjustment is treated as unknown.
Source
Thrown at src/cmd/compile/internal/inline/inlheur/scoring.go:134
}
func parseScoreAdj(val string) error {
clauses := strings.Split(val, "/")
if len(clauses) == 0 {
return fmt.Errorf("no clauses")
}
for _, clause := range clauses {
elems := strings.Split(clause, ":")
if len(elems) < 2 {
return fmt.Errorf("clause %q: expected colon", clause)
}
if len(elems) != 2 {
return fmt.Errorf("clause %q has %d elements, wanted 2", clause,
len(elems))
}
adj, ok := adjStringToVal(elems[0])
if !ok {
return fmt.Errorf("clause %q: unknown adjustment", clause)
}
val, err := strconv.Atoi(elems[1])
if err != nil {
return fmt.Errorf("clause %q: malformed value: %v", clause, err)
}
adjValues[adj] = val
}
return nil
}
func adjValue(x scoreAdjustTyp) int {
if val, ok := adjValues[x]; ok {
return val
} else {
panic("internal error unregistered adjustment type")
}
}
View on GitHub (pinned to b6b368adc5)
Solutions
- Use only adjustment names defined in the scoreAdjustTyp const block (panicPathAdj, initFuncAdj, inLoopAdj, passConstToIfAdj, passConstToNestedIfAdj, passConcreteToItfCallAdj, passConcreteToNestedItfCallAdj, passFuncToIndCallAdj, passFuncToNestedIndCallAdj, passInlinableFuncToIndCallAdj, passInlinableFuncToNestedIndCallAdj, returnFeedsConstToIfAdj, returnFeedsFuncToIndCallAdj, returnFeedsInlinableFuncToIndCallAdj, returnFeedsConcreteToInterfaceCallAdj).
- Run adjStringToVal on the candidate name to confirm before passing the flag.
- Update the name to match the current Go tree if it was renamed.
Example fix
// before -d=inlheuradjustments=panicPath:40 // after -d=inlheuradjustments=panicPathAdj:40
Defensive patterns
Strategy: validation
Validate before calling
// Build the set of valid adjustment names once.
valid := map[string]bool{}
for adj := scoreAdjustTyp(1); adj < sentinelScoreAdj; adj <<= 1 {
valid[adj.String()] = true
}
for _, c := range strings.Split(val, "/") {
name := strings.SplitN(c, ":", 2)[0]
if !valid[name] {
return fmt.Errorf("unknown adjustment %q", name)
}
} Prevention
- Source adjustment names from the scoreAdjustTyp String() outputs only.
- Update flag docs whenever the enum is renamed.
When it happens
Trigger: A clause like FooAdj:40 where FooAdj is not one of panicPathAdj, initFuncAdj, inLoopAdj, passConstToIfAdj, etc.; adjStringToVal returns ok=false and parseScoreAdj reports the unknown adjustment.
Common situations: Compiler development: typo in adjustment name, using an outdated name after a rename, or copy-pasting a name from a different Go version whose enum differs.
Related errors
- no clauses
- clause %q: expected colon
- clause %q has %d elements, wanted 2
- clause %q: malformed value: %v
- marshal error %v
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/61371d1b364f5730.
Report an issue: GitHub.