{"record":{"id":"7e332d60fa20f49f","repo":"jax-ml/jax","slug":"unsupported-range-type-type-r","errorCode":null,"errorMessage":"Unsupported range type: {type(r)}.","messagePattern":"Unsupported range type: (.+?)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/pallas/mosaic/interpret/utils.py","lineNumber":362,"sourceCode":"      assert 0 <= r\n      if r >= d:\n        return True\n    elif isinstance(r, slice):\n      assert r.start is not None and 0 <= r.start\n      assert r.stop is not None and 0 <= r.stop\n\n      if r.step is None:\n        if r.stop > d:\n          return True\n      else:\n        assert 0 <= r.step\n        num_elements_in_slice = (r.stop - r.start + r.step - 1) // r.step\n        if num_elements_in_slice > 0:\n          last_index = r.start + (num_elements_in_slice - 1) * r.step\n          if last_index >= d:\n            return True\n    else:\n      raise ValueError(f\"Unsupported range type: {type(r)}.\")\n  return False\n\n\ndef clip_range_to_shape(\n    rnge: tuple[slice | int, ...], shape: tuple[int, ...]\n) -> tuple[slice | int, ...] | None:\n  \"\"\"Clips `slice`s in `rnge` to the `shape`. Returns None if `rnge` is entirely out of bounds.\"\"\"\n  result: list[slice | int] = []\n  for r, l in zip(rnge, shape, strict=True):\n    if isinstance(r, int):\n      if r >= l:\n        return None\n      result.append(r)\n    elif isinstance(r, slice):\n      if r.start >= l:\n        return None\n      result.append(slice(r.start, min(r.stop, l), r.step))\n    else:","sourceCodeStart":344,"sourceCodeEnd":380,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/pallas/mosaic/interpret/utils.py#L344-L380","documentation":"is_range_out_of_bounds_for_shape encountered an index element that is neither an int nor a slice (e.g. None, ellipsis, or array). The bounds checker only supports int/slice ranges.","triggerScenarios":"Calling Buffer.__setitem__ (or the util directly) with a range tuple containing None/ellipsis/numpy arrays instead of ints or slices.","commonSituations":"Passing raw numpy-style indexing (e.g. [None, :] or [...]) into interpret-mode shared memory writes; converting slices lazily so None sneaks through.","solutions":["Normalize the index: expand ellipsis/None and convert to int/slice tuples before writing","Use _normalize_range-style helpers on the range before indexing","Convert numpy scalars to Python ints"],"exampleFix":"// before\nsmem[None, 0:16] = v\n// after\nsmem[0:1, 0:16] = v","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"def is_supported_range(rnge):\n    return all(isinstance(r, (int, slice)) for r in rnge)","tryCatchPattern":null,"preventionTips":["Normalize indexes (expand ellipsis, drop None, convert numpy ints) before writing to interpret Buffers","Only use int/slice tuples for shared-memory writes"],"tags":["jax","pallas","mosaic","indexing","unsupported-type"],"backgroundTag":"unsupported-index-type","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}