golang/go · error
no clauses
Error message
no clauses
What it means
Returned by parseScoreAdj when the score-adjustment flag string, split on "/", yields zero clauses. In practice strings.Split never returns a zero-length slice for a non-empty input (it always returns at least one element), so this branch only triggers when val is "". It guards the parser of the internal flag used to retune inline-heuristic adjustment scores.
Source
Thrown at src/cmd/compile/internal/inline/inlheur/scoring.go:121
if err := parseScoreAdj(base.Debug.InlScoreAdj); err != nil {
base.Fatalf("malformed -d=inlscoreadj argument %q: %v",
base.Debug.InlScoreAdj, err)
}
}
func adjStringToVal(s string) (scoreAdjustTyp, bool) {
for adj := scoreAdjustTyp(1); adj < sentinelScoreAdj; adj <<= 1 {
if adj.String() == s {
return adj, true
}
}
return 0, false
}
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)
}View on GitHub (pinned to b6b368adc5)
Solutions
- Provide a non-empty adjustment string in the expected name:value[/name:value] form (e.g. panicPathAdj:40/initFuncAdj:20).
- If the flag is optional, skip calling parseScoreAdj when the value is empty rather than parsing it.
- Verify the adjustment names against the scoreAdjustTyp enum (panicPathAdj, initFuncAdj, inLoopAdj, ...).
Defensive patterns
Strategy: validation
Validate before calling
// Skip parsing an unset flag value.
val := flag.Lookup("inlheuradjustments").Value.String()
if strings.TrimSpace(val) == "" {
return nil // no adjustments to apply
}
return parseScoreAdj(val) Prevention
- Treat empty flag values as 'unset' before parsing.
- Document the expected name:value[/name:value] syntax in the flag help text.
When it happens
Trigger: An internal flag value for inlheur score adjustments is parsed with parseScoreAdj and produces an empty clauses slice; effectively only when the flag value is the empty string passed through a code path that does not pre-filter it.
Common situations: Compiler development: passing -d=inlheuradjustments= (empty) or wiring the flag value from an unset environment variable. End users of released Go should never see this.
Related errors
- clause %q: expected colon
- clause %q has %d elements, wanted 2
- clause %q: unknown adjustment
- clause %q: malformed value: %v
- marshal error %v
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/36ff6225b4f11a47.
Report an issue: GitHub.