api: CompiledRegex should carry its MatchMode to prevent silent misuse
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
Start by locating CompiledRegex, compile, matchCompiled, searchCompiled, and desugar, then inspect the CLI entry point in LckGrep.lean and the affected tests. Decide which proposed API shape is intended, update callers and tests, and verify that mismatched match modes can no longer be used silently.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Lean
- Stars
- 2
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from lambdaclass/lambda_compiler_kit
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 48/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 50/100
All issues in lambdaclass/lambda_compiler_kit
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
elastic/gradle-plugins#156 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Fission-AI/OpenSpec#1960 ·
-
area/config comp/tools P2 type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
NousResearch/hermes-agent#119942 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100