Skip to content

Commit

Permalink
[ fix ] Don't include type of binder for let in addRefs
Browse files Browse the repository at this point in the history
  • Loading branch information
dunhamsteve committed Jul 27, 2023
1 parent 870bc82 commit e67fdef
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@

* Constant folding of trivial let statements and `believe_me`.

* Fixed an issue that caused total functions containing a `let` to be rejected
as not total.

* Fixed a bug that caused holes to appear unexpectedly during quotation of dependent pairs.

### Library changes
Expand Down
2 changes: 1 addition & 1 deletion src/Core/TT.idr
Original file line number Diff line number Diff line change
Expand Up @@ -1843,7 +1843,7 @@ addRefs ua at ns (Meta fc n i xs)
addRefsArgs ns [] = ns
addRefsArgs ns (t :: ts) = addRefsArgs (addRefs ua at ns t) ts
addRefs ua at ns (Bind fc x (Let _ c val ty) scope)
= addRefs ua at (addRefs ua at (addRefs ua at ns val) ty) scope
= addRefs ua at (addRefs ua at ns val) scope
addRefs ua at ns (Bind fc x b scope)
= addRefs ua at (addRefs ua at ns (binderType b)) scope
addRefs ua at ns (App _ (App _ (Ref fc _ name) x) y)
Expand Down
2 changes: 1 addition & 1 deletion tests/Main.idr
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ idrisTestsTotality = MkTestPool "Totality checking" [] Nothing
"total001", "total002", "total003", "total004", "total005",
"total006", "total007", "total008", "total009", "total010",
"total011", "total012", "total013", "total014", "total015",
"total016", "total017", "total018", "total019"
"total016", "total017", "total018", "total019", "total020"
]

-- This will only work with an Idris compiled via Chez or Racket, but at
Expand Down
2 changes: 1 addition & 1 deletion tests/idris2/debug001/expected
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Compiled: \ {arg:1}, {arg:2} => case {arg:2} of
{ Prelude.Basics.Lin {tag = 0} [nil] => Prelude.Basics.Lin {tag = 0} [nil]
; Prelude.Basics.(:<) {tag = 1} [cons] {e:2} {e:3} => let rest = Prelude.Types.SnocList.filter {arg:1} {e:2} incase {arg:1} {e:3} of { 1 => Prelude.Basics.(:<) {tag = 1} [cons] rest {e:3}; 0 => rest}
}
Refers to: Prelude.Basics.SnocList, Prelude.Basics.Lin, Prelude.Types.SnocList.case block in filter, Prelude.Types.SnocList.filter
Refers to: Prelude.Basics.Lin, Prelude.Types.SnocList.case block in filter, Prelude.Types.SnocList.filter
Refers to (runtime): Prelude.Basics.Lin, Prelude.Basics.(:<), Prelude.Types.SnocList.filter
Flags: total
Size change: Prelude.Types.SnocList.filter: [Just (0, Same), Just (1, Same), Just (2, Smaller)]
Expand Down
23 changes: 23 additions & 0 deletions tests/idris2/total020/Check.idr
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
record RF infot where
constructor MkRF
info : infot
op : RF infot -> RF infot

total
test : RF a -> (a -> RF b) -> RF b
test a f = let foo = f a.info in foo

total
test2 : RF a -> (a -> RF b) -> RF b
test2 a f = f a.info

total
test3 : RF a -> (a -> RF b) -> RF b
test3 a f = let foo = a in f foo.info

total
test4 : RF a -> (a -> RF b) -> RF b
test4 a f = let foo : RF b
foo = f a.info
in foo

1 change: 1 addition & 0 deletions tests/idris2/total020/expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1/1: Building Check (Check.idr)
3 changes: 3 additions & 0 deletions tests/idris2/total020/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
rm -rf build

$1 --no-color --console-width 0 --no-banner --check Check.idr

0 comments on commit e67fdef

Please sign in to comment.