Package: purescript-lua-exceptions
File: src/Effect/Exception.lua
Function: catchException
Class: arity-drop Severity: high
In the error branch the handler result is returned without being executed. The handler c has PureScript type (Error -> Effect a); applying c(errorOrResult) yields an Effect a, which in this backend is a zero-arg thunk that must be invoked to actually run the effect and produce the value. The JS FFI calls it as c(e)() — note the trailing call. The Lua code stops at c(errorOrResult), so catchException returns the unexecuted thunk (a function) instead of the handled value, and the handler's side effects never run. Verified under Lua 5.1: with a handler that records a flag and returns a value, after catchException(c)(t)() the flag stayed false and the result was a function, not the value. This also breaks the library's own try (try = catchException (pure <<< Left) (Right <$> action)): on a thrown error try returns a function instead of Left error, so every downstream pattern-match on the Either fails.
Current (Lua):
else
return c(errorOrResult)
end
Expected: JS runs the handler effect: return c(e)(). catchException must return the value produced by running the handler's Effect, i.e. apply the returned thunk.
Proposed fix:
Change `return c(errorOrResult)` to `return c(errorOrResult)()`.
Found by the FFI audit; reproduced under Lua 5.1.
Package: purescript-lua-exceptions
File:
src/Effect/Exception.luaFunction:
catchExceptionClass: arity-drop Severity: high
In the error branch the handler result is returned without being executed. The handler c has PureScript type (Error -> Effect a); applying c(errorOrResult) yields an Effect a, which in this backend is a zero-arg thunk that must be invoked to actually run the effect and produce the value. The JS FFI calls it as c(e)() — note the trailing call. The Lua code stops at c(errorOrResult), so catchException returns the unexecuted thunk (a function) instead of the handled value, and the handler's side effects never run. Verified under Lua 5.1: with a handler that records a flag and returns a value, after catchException(c)(t)() the flag stayed false and the result was a function, not the value. This also breaks the library's own
try(try = catchException (pure <<< Left) (Right <$> action)): on a thrown errortryreturns a function instead ofLeft error, so every downstream pattern-match on the Either fails.Current (Lua):
Expected: JS runs the handler effect:
return c(e)(). catchException must return the value produced by running the handler's Effect, i.e. apply the returned thunk.Proposed fix:
Found by the FFI audit; reproduced under Lua 5.1.