`String.Slice.revSplit` drops the empty piece at the start of the slice
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 78/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Ambito
- backend-api-design
Direzione di ricerca
Inizia con RevSplitIterator.step in src/Init/Data/String/Slice/Pattern.lean e confronta il suo caso di ricerca completata con SplitIterator. Riproduci il problema con il programma Lean minimo nel report, includendo i casi di slice vuota e di separatore iniziale. Il lavoro è completato quando revSplit restituisce gli stessi elementi di split in ordine inverso e la suite di test esistente copre questo comportamento.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Prerequisites
- Check that your issue is not already filed: searched for
revSplit,Slice.split,String.Slice splitandsplit empty slice. - Reduce the issue to a minimal, self-contained, reproducible test case. Avoid dependencies to Mathlib or Batteries.
- Test your test case against the latest nightly release.
Description
String.Slice.revSplit leaves out the leftmost piece when it is empty. A slice that starts with a separator, or an empty slice, gives one piece fewer than String.Slice.split. A separator at the end does give an empty piece, so the two ends behave differently:
def main : IO Unit := do
IO.println (repr <| (",x".toSlice.split ',').toList.map (·.copy))
IO.println (repr <| (",x".toSlice.revSplit ',').toList.map (·.copy))
IO.println (repr <| ("x,".toSlice.revSplit ',').toList.map (·.copy))
IO.println (repr <| ("".toSlice.revSplit ',').toList.map (·.copy))
lean --run RevSplit.lean
# expected: # actual:
["", "x"] ["", "x"]
["x", ""] ["x"]
["", "x"] ["", "x"]
[""] []
Likewise "aa".toSlice.split 'a' gives three empty pieces and "aa".toSlice.revSplit 'a' gives two. The Char → Bool pattern form behaves the same way.
The revSplit docstring matches the split docstring apart from the direction ("starting from the end of the slice and traversing towards the start ... If multiple subslices in a row match the pattern, the resulting list will contain empty slices"), so revSplit should give the pieces of split in reverse order.
In RevSplitIterator.step (src/Init/Data/String/Slice/Pattern.lean), when the searcher is done, the remaining piece s.sliceTo currPos is yielded only if currPos ≠ s.startPos. The forward SplitIterator yields its remaining piece unconditionally.
Expected behavior: revSplit gives the same pieces as split, in reverse order.
Actual behavior: the leftmost empty piece is missing.
Versions
4.37.0-nightly-2026-11-05 ["x"] / []
4.36.0-rc2 ["x"] / []
4.35.0 ["x"] / []
These are on macOS arm64 (official toolchains via elan), and Linux x86_64 gives the same results. Nothing under src/Init/Data/String/ has changed on master since the nightly. The code came in with #10514.
Impact
Add 👍 to issues you consider important. If others are impacted by this issue, please ask
them to add 👍 to it.
Found by an automated differential tester (ephyra); this report was drafted with AI assistance.
- Lingua principale
- Lean
- Stelle
- 10.3k
- Fork
- 1.1k
- Merge medio
- 19h 8m
- PR unite (30g)
- 421
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di leanprover/lean4
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
leanprover/lean4#16681 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
leanprover/lean4#16299 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
leanprover/lean4#16257 ·
I maintainer di solito rispondono entro 1 giorno
-
`IO.FS.realPath` reports every failure as `noFileOrDirectory` instead of classifying by `errno`Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
leanprover/lean4#15683 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
leanprover/lean4#15626 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di leanprover/lean4
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
vllm-project/vllm-sail#398 ·
I maintainer di solito rispondono entro 1 giorno
-
kubernetes-ingestor: fetchCRDMapping() runs even when crossplane.enabled is false, logging a 403 ERROR every runForse già presa @kc9ddi l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
TeraSky-OSS/backstage-plugins#228 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
bug good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
nightscout/nocturne#4057 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
opendatalab/MinerU#5800 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno