{"record":{"id":"9f27734f02e012de","repo":"jax-ml/jax","slug":"dynamic-slice-unrecognized-index-pidx-index-at","errorCode":null,"errorMessage":"dynamic_slice: unrecognized index {pidx.index} at position {position}.","messagePattern":"dynamic_slice: unrecognized index (.+?) at position (.+?)\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"jax/_src/numpy/indexing.py","lineNumber":510,"sourceCode":"      elif pidx.typ == IndexType.DYNAMIC_SLICE:\n        assert isinstance(pidx.index, indexing.Slice)\n        if pidx.index.stride != 1:\n          raise TypeError(\"dynamic_slice: only unit steps supported in slice.\"\n                          f\" Got {pidx.index} at position {position}\")\n      elif pidx.typ == IndexType.SLICE:\n        assert isinstance(pidx.index, slice)\n        if pidx.index.step is not None and pidx.index.step not in [-1, 1]:\n          raise TypeError(\"dynamic_slice: only unit steps supported in slice.\"\n                          f\" Got {pidx.index} at position {position}\")\n      elif pidx.typ == IndexType.ARRAY:\n        if isinstance(pidx.index, Sequence) or np.shape(pidx.index) != ():  # pyrefly: ignore[no-matching-overload]\n          raise TypeError(\"dynamic_slice: only scalar indices allowed.\"\n                          f\" Got index of type {type(pidx.index)} at position {position}\")\n      elif pidx.typ == IndexType.BOOLEAN:\n        raise TypeError(\"dynamic_slice: indices must be scalars or slices.\"\n                        f\" Got index of type {type(pidx.index)} at position {position}\")\n      else:\n        raise TypeError(f\"dynamic_slice: unrecognized index {pidx.index} at position {position}.\")\n\n    start_indices: list[ArrayLike] = []\n    slice_sizes: list[int] = []\n    rev_axes: list[int] = []\n    squeeze_axes: list[int] = []\n    newaxis_dims: list[int] = []\n\n    expanded = self.expand_ellipses()\n    trivial_slicing = True\n    for pidx in expanded.indices:\n      if pidx.typ in [IndexType.BOOLEAN, IndexType.ELLIPSIS]:\n        raise RuntimeError(f\"Internal: unexpected index encountered: {pidx}\")\n      elif pidx.typ == IndexType.NONE:\n        # Expanded axes indices are based on the rank of the array after slicing\n        # (tracked by start_indices) and squeezing (tracked by squeeze_axes), and\n        # expand_dims inserts dimensions in order, so we must also account for\n        # previous expanded dimensions.\n        newaxis_dims.append(len(start_indices) - len(squeeze_axes) + len(newaxis_dims))","sourceCodeStart":492,"sourceCodeEnd":528,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/numpy/indexing.py#L492-L528","documentation":"A catch-all TypeError for an index whose classified IndexType does not match any known category (integer, slice, ellipsis, none, array, boolean, dynamic_slice) during dynamic-slice lowering.","triggerScenarios":"Passing an exotic/unsupported index object (custom class with __index__, partially-traced objects, or an internal IndexType added without dynamic-slice support) to dynamic-slice-based indexing.","commonSituations":"Custom index-like objects passed to x.at[...]; version mismatches where new index types aren't supported by the dynamic path; rarely hit in normal use.","solutions":["Stick to plain int, slice, None, Ellipsis, and scalar tracer indices","Convert custom index objects to int or jnp scalar before indexing","Report/check JAX version if using jax.indexing constructs that should be supported"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"allowed = (int, slice, type(None), type(Ellipsis))\nassert all(i is Ellipsis or i is None or isinstance(i, allowed) or hasattr(i, 'dtype') or hasattr(i, '__index__') for i in idx_tuple)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Stick to plain int, slice, None, and Ellipsis indices","Avoid custom index objects in JAX indexing expressions"],"tags":["jax","indexing","unsupported-index","dynamic-slice"],"backgroundTag":"invalid-index-type","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}