From 0e31dda702cffe9c52a45b0443da549bc8ad00e6 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Sun, 13 Jul 2014 06:14:23 -0400 Subject: Fix off-by-one error in less-safe FFI wrapper generation --- src/corify.sml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/corify.sml') diff --git a/src/corify.sml b/src/corify.sml index b08ef7eb..162ae1ab 100644 --- a/src/corify.sml +++ b/src/corify.sml @@ -1203,8 +1203,13 @@ fun corifyDecl mods (all as (d, loc : EM.span), st) = L'.TFun (dom, ran) => (L'.TFun (dom, addLastBit ran), #2 t) | _ => (L'.TFun ((L'.TRecord (L'.CRecord ((L'.KType, loc), []), loc), loc), t), loc) - val e = (L'.EFfiApp (m, x, makeArgs (numArgs t' - 1, t', [])), loc) - val (e, tTrans) = if isTransactional t' then + val isTrans = isTransactional t' + val e = (L'.EFfiApp (m, x, makeArgs (numArgs t' - + (if isTrans then + 0 + else + 1), t', [])), loc) + val (e, tTrans) = if isTrans then ((L'.EAbs ("_", (L'.TRecord (L'.CRecord ((L'.KType, loc), []), loc), loc), getRan t', e), loc), addLastBit t') else (e, t') @@ -1216,7 +1221,7 @@ fun corifyDecl mods (all as (d, loc : EM.span), st) = | Source.ServerOnly => Settings.addServerOnly name | Source.JsFunc s => Settings.addJsFunc (name, s)) modes; - if isTransactional t' andalso not (Settings.isBenignEffectful name) then + if isTrans andalso not (Settings.isBenignEffectful name) then Settings.addEffectful name else (); -- cgit v1.2.3