Skip to content

[fork-ffi] exceptions: name — PureScript name :: Error -> String returns the error's name,… #83

@Unisay

Description

@Unisay

Package: purescript-lua-exceptions
File: src/Effect/Exception.lua
Function: name
Class: semantics Severity: medium

PureScript name :: Error -> String returns the error's name, falling back to 'Error' (JS: e.name || "Error"). For an Error built with error msg, the JS result is the constant 'Error'. In this Lua FFI an Error is just the message string and there is no name field, but name is implemented as identity, so name (error "boom") returns 'boom' instead of 'Error'. This is a direct behavioural divergence from the documented contract ('Get the error name when defined, or fallback to Error').

Current (Lua):

name = (function(err) return err end)

Expected: name (error msg) should be the constant "Error" (the JS fallback), since the string Error model carries no distinct name.

Proposed fix:

Return the constant: `name = (function(_err) return "Error" end)`.

Found by the FFI audit; reproduced under Lua 5.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions