golang/go · error

clause %q: malformed value: %v

Error message

clause %q: malformed value: %v

What it means

Returned by parseScoreAdj when strconv.Atoi fails to parse the value portion of a clause. Each clause is name:integer; if the integer half is non-numeric, Atoi returns an error that is wrapped into the clause-specific message.

Source

Thrown at src/cmd/compile/internal/inline/inlheur/scoring.go:138

	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")
	}
}

var mayMustAdj = [...]struct{ may, must scoreAdjustTyp }{
	{may: passConstToNestedIfAdj, must: passConstToIfAdj},
	{may: passConcreteToNestedItfCallAdj, must: passConcreteToItfCallAdj},
	{may: passFuncToNestedIndCallAdj, must: passFuncToNestedIndCallAdj},

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Use a plain decimal integer for the value (panicPathAdj:40).
  2. Strip whitespace and any sign/unit suffixes from the value.
  3. If negative tuning is intended, use the signed form Atoi accepts (e.g. panicPathAdj:-5).

Example fix

// before
-d=inlheuradjustments=panicPathAdj:high
// after
-d=inlheuradjustments=panicPathAdj:40
Defensive patterns

Strategy: validation

Validate before calling

// Atoi-validate the value half up front.
for _, c := range strings.Split(val, "/") {
    parts := strings.SplitN(c, ":", 2)
    if _, err := strconv.Atoi(parts[1]); err != nil {
        return fmt.Errorf("value %q must be an integer", parts[1])
    }
}

Prevention

When it happens

Trigger: A clause like panicPathAdj:high or panicPathAdj:4.0 where elems[1] is not a base-10 integer; strconv.Atoi returns err and parseScoreAdj wraps it.

Common situations: Compiler development: typo in the value, using a float, or pasting a value with surrounding whitespace/signs Atoi rejects.

Understand the failure class

Related errors


AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12). Data as JSON: /api/errors/0c6ef77444ddb182. Report an issue: GitHub.