diff options
author | Adam Chlipala <adam@chlipala.net> | 2014-07-13 06:14:23 -0400 |
---|---|---|
committer | Adam Chlipala <adam@chlipala.net> | 2014-07-13 06:14:23 -0400 |
commit | 0e31dda702cffe9c52a45b0443da549bc8ad00e6 (patch) | |
tree | e93a63fc00a79d48506bdc2ee775d187d567eeaf | |
parent | ee2eb6ac79b2a23a998e8feb4043bbf593e9bc5c (diff) |
Fix off-by-one error in less-safe FFI wrapper generation
-rw-r--r-- | src/corify.sml | 11 | ||||
-rw-r--r-- | tests/lessSafeFfi.ur | 5 |
2 files changed, 11 insertions, 5 deletions
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 (); diff --git a/tests/lessSafeFfi.ur b/tests/lessSafeFfi.ur index da79bfdc..ec96db0a 100644 --- a/tests/lessSafeFfi.ur +++ b/tests/lessSafeFfi.ur @@ -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 <xml><body> (*{[foo 42]}, {[q]}*) - <button onclick={fn _ => bup 32}/> + <button onclick={fn _ => bup "asdf"}/> </body></xml> fun main () = return <xml><body> |