File tree Expand file tree Collapse file tree 6 files changed +28
-8
lines changed
tests/idris2/linear/linear018 Expand file tree Collapse file tree 6 files changed +28
-8
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ should target this file (`CHANGELOG_NEXT`).
3636 typically happens when a numeric literal or an ambiguous name appears in an
3737 ` impossible ` clause.
3838* Do not inline ` Core.sequence ` , because it is recursively defined.
39+ * Fixed incorrect argument multiplicity when using an as-pattern (#3687 ).
3940
4041### Building/Packaging changes
4142
Original file line number Diff line number Diff line change @@ -310,14 +310,17 @@ findLinear top bound rig tm
310310 findLinArg _ _ [] = pure []
311311
312312setLinear : List (Name, RigCount) -> Term vars -> Term vars
313- setLinear vs (Bind fc x b@(PVar {}) sc)
314- = case lookup x vs of
315- Just c' => Bind fc x (setMultiplicity b c') (setLinear vs sc)
316- _ => Bind fc x b (setLinear vs sc)
317- setLinear vs (Bind fc x b@(PVTy {}) sc)
318- = case lookup x vs of
319- Just c' => Bind fc x (setMultiplicity b c') (setLinear vs sc)
320- _ => Bind fc x b (setLinear vs sc)
313+ setLinear vs (Bind fc x b sc)
314+ = do let b' = case guard (isPatternBinder b) *> lookup x vs of
315+ Just c' => setMultiplicity b c'
316+ Nothing => b
317+ Bind fc x b' (setLinear vs sc)
318+ where
319+ isPatternBinder : Binder a -> Bool
320+ isPatternBinder (PVar {}) = True
321+ isPatternBinder (PVTy {}) = True
322+ isPatternBinder (PLet {}) = True
323+ isPatternBinder _ = False
321324setLinear vs tm = tm
322325
323326-- Combining multiplicities on LHS:
Original file line number Diff line number Diff line change 1+ data X : Nat -> Type where
2+ XS : X (S n)
3+
4+ f : () -> (n : Nat ) -> X n -> Nat
5+ f b@() . (S m) XS = ? hole
Original file line number Diff line number Diff line change 1+ 1/1: Building Issue3687 (Issue3687.idr)
2+ Main> b : ()
3+ 0 m : Nat
4+ ------------------------------
5+ hole : Nat
6+ Main>
7+ Bye for now!
Original file line number Diff line number Diff line change 1+ :t hole
Original file line number Diff line number Diff line change 1+ . ../../../testutils.sh
2+
3+ idris2 Issue3687.idr < input
You can’t perform that action at this time.
0 commit comments