Substr panicked with a slice-bounds error when a negative length trimmed more runes than remained after pos, because stopIdx (strLn + length) could fall before pos. Clamp stopIdx to pos so an over-long negative trim returns an empty string, matching the existing pos >= strLn guard.