Package: purescript-lua-exceptions
File: src/Effect/Exception.lua
Function: errorWithCause
Class: semantics Severity: low
In JS errorWithCause msg cause is new Error(msg, { cause }): the message remains exactly msg and the cause is stored separately, so message (errorWithCause msg cause) returns msg. The Lua version concatenates the cause into the message string ('msg\nCaused by: cause'). Because message is identity, message (errorWithCause "a" (error "b")) returns 'a\nCaused by: b' instead of 'a', diverging from the upstream contract that message returns the original message.
Current (Lua):
errorWithCause = (function(msg) return function(cause) return msg .. "\nCaused by: " .. cause end end)
Expected: message of an errorWithCause-built Error should equal the supplied msg (cause stored without altering the message).
Proposed fix:
With the flat-string Error model, faithfully preserving both message and a separate cause requires a richer representation (e.g. a table {message=..., cause=...}) and corresponding message/name/show readers. Minimally, keep the message pristine and store the cause out-of-band rather than concatenating into the message.
Found by the FFI audit; reproduced under Lua 5.1.
Package: purescript-lua-exceptions
File:
src/Effect/Exception.luaFunction:
errorWithCauseClass: semantics Severity: low
In JS
errorWithCause msg causeisnew Error(msg, { cause }): the message remains exactly msg and the cause is stored separately, somessage (errorWithCause msg cause)returns msg. The Lua version concatenates the cause into the message string ('msg\nCaused by: cause'). Because message is identity,message (errorWithCause "a" (error "b"))returns 'a\nCaused by: b' instead of 'a', diverging from the upstream contract that message returns the original message.Current (Lua):
Expected: message of an errorWithCause-built Error should equal the supplied msg (cause stored without altering the message).
Proposed fix:
Found by the FFI audit; reproduced under Lua 5.1.