lambdaclass / lambdaclass/lambda_compiler_kit
api: CompiledRegex should carry its MatchMode to prevent silent misuse
Nessuno ha ancora preso questa issue.
- Lingua principale
- Lean
- Stelle
- 2
- Fork
- 1
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Problem
CompiledRegex stores only nfa : GlushkovNfa with no record of the MatchMode used during compilation. Both matchCompiled and searchCompiled call the identical Glushkov.matchString underneath — the mode distinction is only enforced inside desugar (which wraps unanchored patterns with .* in search mode).
This means a caller who compiles with .search and then calls matchCompiled instead of searchCompiled silently gets wrong semantics — no error, no warning.
-- Silent misuse: compiled for search, used as fullMatch
let compiled ← compile pattern .search
let result := matchCompiled compiled input -- wrong! should be searchCompiled
Proposed fix
Add a mode : MatchMode field to CompiledRegex and assert (or dispatch) on it in matchCompiled/searchCompiled:
structure CompiledRegex where
nfa : Glushkov.GlushkovNfa
mode : MatchMode
deriving Repr
Option A: panic/error if wrong function called for mode.
Option B: merge into a single runCompiled that dispatches based on stored mode.
Option C: remove matchCompiled/searchCompiled and expose only runCompiled.
Option C (single entry point) is cleanest — callers can't pick the wrong function.
Impact
Breaking API change for matchCompiled/searchCompiled. The CLI (LckGrep.lean) and tests need updating.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
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.
Direzione di ricerca
Inizia individuando CompiledRegex, compile, matchCompiled, searchCompiled e desugar, quindi esamina il punto di ingresso della CLI in LckGrep.lean e i test interessati. Decidi quale forma dell’API proposta è quella prevista, aggiorna i chiamanti e i test e verifica che modalità di corrispondenza non compatibili non possano più essere usate silenziosamente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Ambito
- cli, compilers
- Tipo di issue
- Refactoring
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100