# HG changeset patch # User Adam Chlipala # Date 1405246463 14400 # Node ID ec2c7a22df0dd678166574311ea44c12e5ed86ae # Parent cf453f48d28b66c2f8f591410c3512a90107fe48 Fix off-by-one error in less-safe FFI wrapper generation diff -r cf453f48d28b -r ec2c7a22df0d src/corify.sml --- a/src/corify.sml Fri Jul 04 09:41:32 2014 -0400 +++ b/src/corify.sml Sun Jul 13 06:14:23 2014 -0400 @@ -1203,8 +1203,13 @@ 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 @@ | 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 (); diff -r cf453f48d28b -r ec2c7a22df0d tests/lessSafeFfi.ur --- a/tests/lessSafeFfi.ur Fri Jul 04 09:41:32 2014 -0400 +++ b/tests/lessSafeFfi.ur Sun Jul 13 06:14:23 2014 -0400 @@ -1,15 +1,16 @@ ffi foo : int -> int ffi bar serverOnly benignEffectful : int -> transaction unit ffi baz : transaction int +ffi adder : int -> int -> int -ffi bup jsFunc "jsbup" : int -> transaction unit +ffi bup jsFunc "alert" : string -> transaction unit fun other () : transaction page = (*bar 17; q <- baz;*) return (*{[foo 42]}, {[q]}*) -