8000 Support incorrect `slices` package usage for SA1 checks · Issue #1850 · dominikh/go-tools · GitHub
[go: up one dir, main page]

Skip to content

Support incorrect slices package usage for SA1 checks #1850

Open

Description

@g4s8

Some functions in the slices package document argument constraints and panic when those constraints are violated. Staticcheck currently does not report these calls, even when the arguments are constants:

	const size = 20
	sl := make([]int, size)
	_ = slices.Delete(sl, -1, -2)
	_ = slices.Chunk(sl, -1)
	_ = slices.Grow(sl, -1)

e.g.

  • slices.Delete(s, i, j) requires 0 <= i <= j <= len(s)
  • slices.Chunk(s, n) panics if n < 1
  • slices.Grow(s, n) panics if n < 0

Would it make sense to add a check for statically invalid arguments to these functions?

Activity

  1. added
    needs-triage
    on Nov 15, 2026
  2. added and removed
    needs-triage
    on Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0