Skip to content

feat: add errorWithName (upstream v6.1.0 parity) - #5

Merged
Unisay merged 1 commit into
masterfrom
yura/issue-269-fork-ffi-exceptions-errorwithname
Jul 14, 2026
Merged

feat: add errorWithName (upstream v6.1.0 parity)#5
Unisay merged 1 commit into
masterfrom
yura/issue-269-fork-ffi-exceptions-errorwithname

Conversation

@Unisay

Copy link
Copy Markdown
Collaborator

Closespurescript-lua/purescript-lua#269.

Upstream purescript-exceptions v6.1.0 exports errorWithName :: String -> String -> Error and the fork did not, so code written against the registry package failed to compile against the fork. One correction to the issue text: upstream takes the message first and the name second (errorWithName(msg)(name) in the JS FFI), not the other way around; the implementation follows upstream.

The fork models Error as a plain Lua string, so the name is unobservable through this binding: message returns the supplied message and name keeps answering the constant "Error", the same precedent as errorWithCause's dropped cause (documented in the FFI). An observable-name upgrade of the whole Error representation stays a separate issue, as scoped in the issue text. The inherited upstream Exception.js gains the same export so it keeps matching its upstream counterpart.

The regression guard pins message (errorWithName msg name) == msg and the documented name fallback. The whole path is verified: spago build and the pslua link succeed, and the linked module answers message/name as pinned. The commit also adds /dist/ to .gitignore, the same build-artifact gap purescript-lua-console closed in its grouping PR.

Follow-up (not in this PR): exceptions fork patch release, then a package-set bump together with the console grouping fix.

Upstream purescript-exceptions v6.1.0 exports errorWithName :: String ->
String -> Error (message first, name second) and the fork did not, so
code written against the registry package failed to compile against the
fork.
The fork models Error as a plain Lua string, so the name is unobservable
through this binding: message returns the supplied message and name keeps
answering the constant "Error", the same precedent as errorWithCause's
dropped cause (documented in the FFI). An observable-name upgrade of the
whole Error representation would be a separate issue. The inherited
upstream Exception.js gains the same export so it keeps matching its
upstream counterpart.
Extends the regression guard to pin message/name behaviour, and ignores
the dist/ build artifact.
Closespurescript-lua/purescript-lua#269

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds upstream purescript-exceptions v6.1.0 API parity by introducing errorWithName :: String -> String -> Error to this PureScript→Lua fork, plus a Lua-side regression guard to pin the fork’s string-Error semantics.

Changes:

  • Export errorWithName from Effect.Exception and add the corresponding FFI implementations (Lua + JS).
  • Add a Lua regression test asserting message (errorWithName msg name) == msg and that name remains the "Error" fallback in the Lua backend.
  • Ignore /dist/ as an additional build artifact directory.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
FileDescription
test/regression/exception.luaAdds regression coverage for errorWithName behavior in the Lua FFI.
src/Effect/Exception.pursExposes errorWithName in the PureScript API surface.
src/Effect/Exception.luaImplements errorWithName for Lua’s string-Error representation (drops name, preserves message).
src/Effect/Exception.jsImplements errorWithName in the JS FFI to match upstream behavior (e.name = name).
changelog.d/20260714_090000_yura_errorwithname.mdDocuments the new API and its Lua-specific observability limitations.
.gitignoreAdds /dist/ to ignored build artifacts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@UnisayUnisay self-assigned this Jul 14, 2026
@Unisay
Unisay marked this pull request as ready for review July 14, 2026 07:30
@Unisay
Unisay merged commit 88f0404 into masterJul 14, 2026
2 checks passed
@Unisay
Unisay deleted the yura/issue-269-fork-ffi-exceptions-errorwithname branch July 14, 2026 11:00
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[fork-ffi] exceptions: errorWithName is missing from the fork

2 participants

@Unisay