`NameTrie.findLongestPrefix?` returns `none` when the lookup passes through a key-less node before leaving the trie
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
- 86/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Ambito
- backend
Direzione di ricerca
Inizia da PrefixTreeNode.findLongestPrefix? e dal suo ciclo in src/Lean/Data/PrefixTree.lean; l’issue segnala l’assenza del fallback quando una ricerca esce dal trie. Esamina il chiamante AsyncConsts.findPrefix? in src/Lean/Environment.lean per il contesto. Il lavoro è concluso quando entrambe le ricerche nel reproducer restituiscono some 1.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Prerequisites
- Check that your issue is not already filed: searched for
findLongestPrefix,PrefixTree,NameTrieandAsyncConsts. - 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
With keys a and a.b.c, findLongestPrefix? a.b.d returns none, although a is a key and a prefix of a.b.d:
import Lean.Data.NameTrie
open Lean
-- Keys: `a` ↦ 1 and `a.b.c` ↦ 2. The node for `a.b` exists but holds no value.
def t : NameTrie Nat := ((∅ : NameTrie Nat).insert `a 1).insert `a.b.c 2
#eval t.findLongestPrefix? `a.x -- some 1
#eval t.findLongestPrefix? `a.b.d -- none, expected some 1
The docstring of PrefixTreeNode.findLongestPrefix? (src/Lean/Data/PrefixTree.lean) says: "Returns the value of the longest key in t that is a prefix of k, if any."
The first lookup leaves the trie at the node for a, which has a value. The second goes through the node for a.b, which has none, and then leaves the trie. In findLongestPrefix?.loop, the [] case returns val <|> acc?, but the m.get? k = none case returns only val and drops acc?, the best match found higher up.
Expected behavior: some 1 for both lookups.
Actual behavior: some 1, then none.
Versions
4.37.0-nightly-2026-11-05 some 1 / none
4.36.0-rc2 some 1 / none
4.35.0 some 1 / none
These are on macOS arm64 (official toolchains via elan), and Linux x86_64 gives the same results. PrefixTree.lean and NameTrie.lean have not changed on master since the nightly. The function was added in #6691 (v4.17.0).
Additional Information
The in-tree caller is AsyncConsts.findPrefix? in src/Lean/Environment.lean.
A fix is available (one line: | none => val <|> acc?).
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 78/100
leanprover/lean4#16305 ·
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