1
1
mirror of https://github.com/anoma/juvix.git synced 2025-01-05 22:46:08 +03:00

Fix bug in instance termination checking (#2423)

* Closes #2421
This commit is contained in:
Łukasz Czajka 2023-10-04 12:00:48 +02:00 committed by GitHub
parent 76d69b5ef3
commit 6b38543ae3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 4 deletions

View File

@ -82,9 +82,10 @@ paramToExpression = \case
_instanceAppExpression
InstanceParamFun InstanceFun {..} ->
_instanceFunExpression
InstanceParamHole h -> ExpressionHole h
InstanceParamMeta {} ->
impossible
InstanceParamHole h ->
ExpressionHole h
InstanceParamMeta v ->
ExpressionIden (IdenVar v)
paramFromExpression :: HashSet VarName -> Expression -> Maybe InstanceParam
paramFromExpression metaVars e = case e of

View File

@ -27,6 +27,9 @@ checkStrictSubterm :: InstanceParam -> InstanceParam -> Bool
checkStrictSubterm p1 p2 = case p2 of
InstanceParamApp InstanceApp {..} ->
any (checkSubterm p1) _instanceAppArgs
InstanceParamFun InstanceFun {..} ->
checkSubterm p1 _instanceFunLeft
|| checkSubterm p1 _instanceFunRight
_ ->
False

View File

@ -66,6 +66,15 @@ instance
showPairI {A B} {{Show A}} {{Show B}} : Show (A × B) :=
mkShow λ {(x, y) := Show.show x ++str ", " ++str Show.show y};
trait
type T A := mkT { a : A };
instance
tNatI : T Nat := mkT 0;
instance
tFunI {A} {{T A}} : T (A -> A) := mkT \ { a := a };
main : IO :=
printStringLn (Show.show true) >>
printStringLn (f false) >>
@ -82,4 +91,4 @@ main : IO :=
printStringLn (f5 "abba" 3) >>
printStringLn (Show.show {{_}} ["a"; "b"; "c"; "d"]) >>
printStringLn (Show.show (λ{x := not x})) >>
printStringLn (Show.show (3, [1; 2]));
printStringLn (Show.show (3, [1; 2 + T.a 0]));