Skip to content

Commit ffbea6d

Browse files
committed
Use 'unify' rather than 'convert' if possible
'convert' doesn't solve holes, so might reject things that are solvable. This can be an issue when resolving interfaces, because we were using convert for arguments of the invertible holes that arise when trying to resolve them. Fixes #66.
1 parent b2da2fe commit ffbea6d

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/Core/Unify.idr

+13-9
Original file line numberDiff line numberDiff line change
@@ -668,18 +668,22 @@ mutual
668668

669669
headsConvert : {vars : _} ->
670670
{auto c : Ref Ctxt Defs} ->
671-
Env Term vars ->
671+
{auto u : Ref UST UState} ->
672+
UnifyInfo ->
673+
FC -> Env Term vars ->
672674
Maybe (List (NF vars)) -> Maybe (List (NF vars)) ->
673675
Core Bool
674-
headsConvert env (Just vs) (Just ns)
676+
headsConvert mode fc env (Just vs) (Just ns)
675677
= case (reverse vs, reverse ns) of
676678
(v :: _, n :: _) =>
677-
do logNF 10 "Converting" env v
678-
logNF 10 "......with" env n
679-
defs <- get Ctxt
680-
convert defs env v n
679+
do logNF 10 "Unifying head" env v
680+
logNF 10 ".........with" env n
681+
res <- unify mode fc env v n
682+
-- If there's constraints, we postpone the whole equation
683+
-- so no need to record them
684+
pure (isNil (constraints res ))
681685
_ => pure False
682-
headsConvert env _ _
686+
headsConvert mode fc env _ _
683687
= do log 10 "Nothing to convert"
684688
pure True
685689

@@ -707,7 +711,7 @@ mutual
707711
nty
708712
-- If the rightmost arguments have the same type, or we don't
709713
-- know the types of the arguments, we'll get on with it.
710-
if !(headsConvert env vargTys nargTys)
714+
if !(headsConvert mode fc env vargTys nargTys)
711715
then
712716
-- Unify the rightmost arguments, with the goal of turning the
713717
-- hole application into a pattern form
@@ -1436,7 +1440,7 @@ retryGuess mode smode (hid, (loc, hname))
14361440
do logTerm 5 ("Failed (det " ++ show hname ++ " " ++ show n ++ ")")
14371441
(type def)
14381442
setInvertible loc (Resolved i)
1439-
pure False -- progress made!
1443+
pure False -- progress not made yet!
14401444
_ => do logTermNF 5 ("Search failed at " ++ show rig ++ " for " ++ show hname)
14411445
[] (type def)
14421446
case smode of

tests/Main.idr

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ idrisTests
9797
"reg001", "reg002", "reg003", "reg004", "reg005", "reg006", "reg007",
9898
"reg008", "reg009", "reg010", "reg011", "reg012", "reg013", "reg014",
9999
"reg015", "reg016", "reg017", "reg018", "reg019", "reg020", "reg021",
100-
"reg022", "reg023", "reg024", "reg025", "reg026", "reg027",
100+
"reg022", "reg023", "reg024", "reg025", "reg026", "reg027", "reg028",
101101
-- Totality checking
102102
"total001", "total002", "total003", "total004", "total005",
103103
"total006", "total007", "total008",

0 commit comments

Comments
 (0)