Skip to content

Commit

Permalink
runtime: move turns discard into UVar (fix #30)
Browse files Browse the repository at this point in the history
  • Loading branch information
gares committed Aug 19, 2019
1 parent 6c45d05 commit 3016e45
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/runtime.ml
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,9 @@ let rec move ~adepth:argsdepth e ?avoid ?(depth=0) ~from ~to_ t =
let tl' = maux e depth tl in
if hd == hd' && tl == tl' then x else Cons(hd',tl')
| Nil -> x
| Discard -> x
| Discard ->
let r = oref C.dummy in
UVar(r,to_,0)

(* fast path with no deref... *)
| UVar _ when delta == 0 && avoid == None -> x
Expand Down
4 changes: 4 additions & 0 deletions tests/sources/heap_discard.elpi
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
main :-
X = [_,2],
X = [1,2],
not(X = [2,2]).
7 changes: 7 additions & 0 deletions tests/suite/elpi_specific.ml
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,10 @@ let () = declare "list_comma"
~typecheck:true
~expectation:Test.Success
()

let () = declare "heap_discard"
~source_elpi:"heap_discard.elpi"
~description:"heapification of _"
~typecheck:true
~expectation:Test.Success
()

0 comments on commit 3016e45

Please sign in to comment.