Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix recursive-function specialisation bug #178

Merged
merged 1 commit into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix issue #177
  • Loading branch information
melsman committed Jun 27, 2024
commit 0675d87cce742d3ed673ad23bb79a496b8962f89
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## MLKit NEWS

* mael 2024-06-27: Fix recursive-function specialisation bug (issue #177).

### MLKit version 4.7.11 is released

* mael 2024-06-04: Tooling bug fixes.
Expand Down
1 change: 1 addition & 0 deletions src/Compiler/Lambda/OptLambda.sml
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,7 @@ structure OptLambda : OPT_LAMBDA =
fun elim_app_arg lv n (e as APP(lv_e as VAR{lvar,...},PRIM(UB_RECORDprim,args),tailpos)) =
if Lvars.eq(lvar,lv) then
let val (_,args) = pick n args
val args = map (elim_app_arg lv n) args
in APP(lv_e,ubargs args,tailpos)
end
else map_lamb (elim_app_arg lv n) e
Expand Down
3 changes: 2 additions & 1 deletion test/all.tst
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,5 @@ structs-avail.sml (* basis library available structu

word-n-vector.sml
int-n-vector.sml
auto2.sml (* ffi auto-conversion *)
auto2.sml (* ffi auto-conversion *)
foldbug.sml
8 changes: 8 additions & 0 deletions test/foldbug.sml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
datatype 'a tree = L | T of 'a tree * 'a * 'a tree

fun fold (_, L, acc) = acc
| fold (f, T (l, x, r), acc) = fold (f, l, (f (x, fold (f, r, acc))))

val v = fold (fn (x, a) => x+a, T(L,40,T(L,2,L)), 0)

val () = print (Int.toString v ^ "\n")
1 change: 1 addition & 0 deletions test/foldbug.sml.out.ok
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
42
Loading