fix: ensure List.filterMap is always csimped (#12348)
Shake accidentally broke this from missing dependency tracking (TBD)
This commit is contained in:
parent
faa2619e53
commit
fae768fb3e
6 changed files with 162 additions and 7 deletions
|
|
@ -506,7 +506,7 @@ Example:
|
|||
[10, 14, 14]
|
||||
```
|
||||
-/
|
||||
@[specialize] def filterMap (f : α → Option β) : List α → List β
|
||||
noncomputable def filterMap (f : α → Option β) : List α → List β
|
||||
| [] => []
|
||||
| a::as =>
|
||||
match f a with
|
||||
|
|
@ -737,12 +737,6 @@ Examples:
|
|||
@[simp, grind =]
|
||||
def rightpad (n : Nat) (a : α) (l : List α) : List α := l ++ replicate (n - length l) a
|
||||
|
||||
/-! ### reduceOption -/
|
||||
|
||||
/-- Drop `none`s from a list, and replace each remaining `some a` with `a`. -/
|
||||
@[inline] def reduceOption {α} : List (Option α) → List α :=
|
||||
List.filterMap id
|
||||
|
||||
/-! ## List membership
|
||||
|
||||
* `L.contains a : Bool` determines, using a `[BEq α]` instance, whether `L` contains an element `· == a`.
|
||||
|
|
|
|||
|
|
@ -120,6 +120,12 @@ Example:
|
|||
split <;> simp [*]
|
||||
exact (go l #[]).symm
|
||||
|
||||
/-! ### reduceOption -/
|
||||
|
||||
/-- Drop `none`s from a list, and replace each remaining `some a` with `a`. -/
|
||||
@[inline] def reduceOption {α} : List (Option α) → List α :=
|
||||
List.filterMap id
|
||||
|
||||
/-! ### foldr -/
|
||||
|
||||
/--
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ public import Init.Data.String.Basic
|
|||
import Init.Data.List.MapIdx
|
||||
import Init.Data.Ord.UInt
|
||||
import Init.Data.ToString.Macro
|
||||
import Init.Data.List.Impl
|
||||
|
||||
public section
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ public import Std.Sat.CNF.Relabel
|
|||
import Init.Data.List.MinMax
|
||||
import Init.Data.Option.Lemmas
|
||||
import Init.Omega
|
||||
import Init.Data.List.Impl
|
||||
|
||||
@[expose] public section
|
||||
|
||||
|
|
|
|||
61
tests/lean/csimpCore.lean
Normal file
61
tests/lean/csimpCore.lean
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
import Std
|
||||
import Lean
|
||||
|
||||
open Lean Compiler LCNF
|
||||
|
||||
/-!
|
||||
`@[csimp]` should only be applied to `noncomputable` defs so we never compile against the wrong
|
||||
version. The following list shows where this is not yet the case.
|
||||
-/
|
||||
|
||||
/--
|
||||
info: (Acc.rec, Acc.recC)
|
||||
(Array.instDecidableEmpEq, Array.instDecidableEmpEqImpl)
|
||||
(Array.instDecidableEq, Array.instDecidableEqImpl)
|
||||
(Array.instDecidableEqEmp, Array.instDecidableEqEmpImpl)
|
||||
(Array.pmap, Array.pmapImpl)
|
||||
(ByteArray.append, ByteArray.fastAppend)
|
||||
(List.append, List.appendTR)
|
||||
(List.dropLast, List.dropLastTR)
|
||||
(List.erase, List.eraseTR)
|
||||
(List.eraseP, List.erasePTR)
|
||||
(List.filter, List.filterTR)
|
||||
(List.findRev?, List.findRev?TR)
|
||||
(List.flatMap, List.flatMapTR)
|
||||
(List.flatten, List.flattenTR)
|
||||
(List.foldr, List.foldrTR)
|
||||
(List.insertIdx, List.insertIdxTR)
|
||||
(List.intercalate, List.intercalateTR)
|
||||
(List.intersperse, List.intersperseTR)
|
||||
(List.leftpad, List.leftpadTR)
|
||||
(List.length, List.lengthTR)
|
||||
(List.map, List.mapTR)
|
||||
(List.merge, List.MergeSort.Internal.mergeTR)
|
||||
(List.mergeSort, List.MergeSort.Internal.mergeSortTR₂)
|
||||
(List.modify, List.modifyTR)
|
||||
(List.pmap, List.pmapImpl)
|
||||
(List.range', List.range'TR)
|
||||
(List.replace, List.replaceTR)
|
||||
(List.replicate, List.replicateTR)
|
||||
(List.set, List.setTR)
|
||||
(List.take, List.takeTR)
|
||||
(List.takeWhile, List.takeWhileTR)
|
||||
(List.unzip, List.unzipTR)
|
||||
(List.zipIdx, List.zipIdxTR)
|
||||
(List.zipWith, List.zipWithTR)
|
||||
(Nat.all, Nat.allTR)
|
||||
(Nat.any, Nat.anyTR)
|
||||
(Nat.fold, Nat.foldTR)
|
||||
(Nat.rec, Nat.recCompiled)
|
||||
(Nat.repeat, Nat.repeatTR)
|
||||
(String.utf8EncodeChar, String.utf8EncodeCharFast)
|
||||
(Thunk.fn, Thunk.fnImpl)
|
||||
(Vector.pmap, Vector.pmapImpl)
|
||||
(String.Slice.Pos.next, String.Slice.Pos.nextFast)
|
||||
-/
|
||||
#guard_msgs in
|
||||
run_elab do
|
||||
let env ← getEnv
|
||||
for (l, r) in CSimp.ext.getState env |>.map.toList.mergeSort (le := (·.1.lt ·.1)) do
|
||||
if !isNoncomputable env l then
|
||||
IO.println (l, r)
|
||||
92
tests/lean/csimpCore.lean.expected.out
Normal file
92
tests/lean/csimpCore.lean.expected.out
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
(Acc.rec, Acc.recC)
|
||||
(Array.instDecidableEmpEq, Array.instDecidableEmpEqImpl)
|
||||
(Array.instDecidableEq, Array.instDecidableEqImpl)
|
||||
(Array.instDecidableEqEmp, Array.instDecidableEqEmpImpl)
|
||||
(Array.pmap, Array.pmapImpl)
|
||||
(ByteArray.append, ByteArray.fastAppend)
|
||||
(List.append, List.appendTR)
|
||||
(List.dropLast, List.dropLastTR)
|
||||
(List.erase, List.eraseTR)
|
||||
(List.eraseIdx, List.eraseIdxTR)
|
||||
(List.eraseP, List.erasePTR)
|
||||
(List.filter, List.filterTR)
|
||||
(List.findRev?, List.findRev?TR)
|
||||
(List.findSomeRev?, List.findSomeRev?TR)
|
||||
(List.flatMap, List.flatMapTR)
|
||||
(List.flatten, List.flattenTR)
|
||||
(List.foldr, List.foldrTR)
|
||||
(List.insertIdx, List.insertIdxTR)
|
||||
(List.intercalate, List.intercalateTR)
|
||||
(List.intersperse, List.intersperseTR)
|
||||
(List.leftpad, List.leftpadTR)
|
||||
(List.length, List.lengthTR)
|
||||
(List.map, List.mapTR)
|
||||
(List.merge, List.MergeSort.Internal.mergeTR)
|
||||
(List.mergeSort, List.MergeSort.Internal.mergeSortTR₂)
|
||||
(List.modify, List.modifyTR)
|
||||
(List.pmap, List.pmapImpl)
|
||||
(List.range', List.range'TR)
|
||||
(List.replace, List.replaceTR)
|
||||
(List.replicate, List.replicateTR)
|
||||
(List.set, List.setTR)
|
||||
(List.take, List.takeTR)
|
||||
(List.takeWhile, List.takeWhileTR)
|
||||
(List.unzip, List.unzipTR)
|
||||
(List.zipIdx, List.zipIdxTR)
|
||||
(List.zipWith, List.zipWithTR)
|
||||
(Nat.all, Nat.allTR)
|
||||
(Nat.any, Nat.anyTR)
|
||||
(Nat.fold, Nat.foldTR)
|
||||
(Nat.rec, Nat.recCompiled)
|
||||
(Nat.repeat, Nat.repeatTR)
|
||||
(String.utf8EncodeChar, String.utf8EncodeCharFast)
|
||||
(Thunk.fn, Thunk.fnImpl)
|
||||
(Vector.pmap, Vector.pmapImpl)
|
||||
(String.Slice.Pos.next, String.Slice.Pos.nextFast)
|
||||
csimpCore.lean:56:0-56:11: error: ❌️ Docstring on `#guard_msgs` does not match generated message:
|
||||
|
||||
info: (Acc.rec, Acc.recC)
|
||||
(Array.instDecidableEmpEq, Array.instDecidableEmpEqImpl)
|
||||
(Array.instDecidableEq, Array.instDecidableEqImpl)
|
||||
(Array.instDecidableEqEmp, Array.instDecidableEqEmpImpl)
|
||||
(Array.pmap, Array.pmapImpl)
|
||||
(ByteArray.append, ByteArray.fastAppend)
|
||||
(List.append, List.appendTR)
|
||||
(List.dropLast, List.dropLastTR)
|
||||
(List.erase, List.eraseTR)
|
||||
+ (List.eraseIdx, List.eraseIdxTR)
|
||||
(List.eraseP, List.erasePTR)
|
||||
(List.filter, List.filterTR)
|
||||
(List.findRev?, List.findRev?TR)
|
||||
+ (List.findSomeRev?, List.findSomeRev?TR)
|
||||
(List.flatMap, List.flatMapTR)
|
||||
(List.flatten, List.flattenTR)
|
||||
(List.foldr, List.foldrTR)
|
||||
(List.insertIdx, List.insertIdxTR)
|
||||
(List.intercalate, List.intercalateTR)
|
||||
(List.intersperse, List.intersperseTR)
|
||||
(List.leftpad, List.leftpadTR)
|
||||
(List.length, List.lengthTR)
|
||||
(List.map, List.mapTR)
|
||||
(List.merge, List.MergeSort.Internal.mergeTR)
|
||||
(List.mergeSort, List.MergeSort.Internal.mergeSortTR₂)
|
||||
(List.modify, List.modifyTR)
|
||||
(List.pmap, List.pmapImpl)
|
||||
(List.range', List.range'TR)
|
||||
(List.replace, List.replaceTR)
|
||||
(List.replicate, List.replicateTR)
|
||||
(List.set, List.setTR)
|
||||
(List.take, List.takeTR)
|
||||
(List.takeWhile, List.takeWhileTR)
|
||||
(List.unzip, List.unzipTR)
|
||||
(List.zipIdx, List.zipIdxTR)
|
||||
(List.zipWith, List.zipWithTR)
|
||||
(Nat.all, Nat.allTR)
|
||||
(Nat.any, Nat.anyTR)
|
||||
(Nat.fold, Nat.foldTR)
|
||||
(Nat.rec, Nat.recCompiled)
|
||||
(Nat.repeat, Nat.repeatTR)
|
||||
(String.utf8EncodeChar, String.utf8EncodeCharFast)
|
||||
(Thunk.fn, Thunk.fnImpl)
|
||||
(Vector.pmap, Vector.pmapImpl)
|
||||
(String.Slice.Pos.next, String.Slice.Pos.nextFast)
|
||||
Loading…
Add table
Reference in a new issue