mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-19 01:01:59 +03:00
Merge pull request #3270 from dunhamsteve/impossible-lam
[ parser ] Add support for impossible lambdas
This commit is contained in:
commit
5d04f89c7b
@ -46,6 +46,9 @@ This CHANGELOG describes the merged but unreleased changes. Please see [CHANGELO
|
||||
environment variable adds to the "Package Search Paths." Functionally this is
|
||||
not a breaking change.
|
||||
|
||||
* The compiler now supports `impossible` in a non-case lambda. You can now
|
||||
write `\ Refl impossible`.
|
||||
|
||||
* The compiler now parses `~x.fun` as unquoting `x` rather than `x.fun`
|
||||
and `~(f 5).fun` as unquoting `(f 5)` rather than `(f 5).fun`.
|
||||
|
||||
|
@ -427,7 +427,7 @@ testsInDir :
|
||||
(poolName : String) ->
|
||||
{default [] requirements : List Requirement} ->
|
||||
{default Nothing codegen : Codegen} ->
|
||||
IO TestPool
|
||||
Lazy (IO TestPool)
|
||||
testsInDir dirName poolName = do
|
||||
Right names <- listDir dirName
|
||||
| Left e => die $ "failed to list " ++ dirName ++ ": " ++ show e
|
||||
|
@ -782,10 +782,21 @@ mutual
|
||||
commit
|
||||
switch <- optional (bounds $ decoratedKeyword fname "case")
|
||||
case switch of
|
||||
Nothing => continueLam
|
||||
Nothing => continueLamImpossible <|> continueLam
|
||||
Just r => continueLamCase r
|
||||
|
||||
where
|
||||
continueLamImpossible : Rule PTerm
|
||||
continueLamImpossible = do
|
||||
lhs <- bounds (opExpr plhs fname indents)
|
||||
end <- bounds (decoratedKeyword fname "impossible")
|
||||
pure (
|
||||
let fc = boundToFC fname (mergeBounds lhs end)
|
||||
alt = (MkImpossible fc lhs.val)
|
||||
fcCase = boundToFC fname lhs
|
||||
n = MN "lcase" 0 in
|
||||
(PLam fcCase top Explicit (PRef fcCase n) (PInfer fcCase) $
|
||||
PCase (virtualiseFC fc) [] (PRef fcCase n) [alt]))
|
||||
|
||||
bindAll : List (RigCount, WithBounds PTerm, PTerm) -> PTerm -> PTerm
|
||||
bindAll [] scope = scope
|
||||
|
2
tests/idris2/error/perror032/LambdaImpossible.idr
Normal file
2
tests/idris2/error/perror032/LambdaImpossible.idr
Normal file
@ -0,0 +1,2 @@
|
||||
foo : 2 = 3 -> Void
|
||||
foo = (\Refl impossible)
|
1
tests/idris2/error/perror032/expected
Normal file
1
tests/idris2/error/perror032/expected
Normal file
@ -0,0 +1 @@
|
||||
1/1: Building LambdaImpossible (LambdaImpossible.idr)
|
3
tests/idris2/error/perror032/run
Normal file
3
tests/idris2/error/perror032/run
Normal file
@ -0,0 +1,3 @@
|
||||
. ../../../testutils.sh
|
||||
|
||||
check LambdaImpossible.idr
|
Loading…
Reference in New Issue
Block a user