Skip to content

showNumberImpl uses Lua tostring — wrong format vs PureScript show (0.0, NaN, Infinity, exponents) #9

Closed

Description

@Unisay

Data/Show.lua showNumberImpl = tostring, but Lua 5.1 tostring does not match PureScript/JS show :: Number -> String:

value PureScript show Lua tostring
0.0 0.0 0
500.0 500.0 500
1e10 10000000000.0 10000000000
1/0 Infinity inf
-1/0 -Infinity -inf
0/0 NaN -nan

So integral Numbers lose the .0, and infinities/NaN print Lua spellings. This is the same class as the showString/showArray FFI divergences. It blocks reviving the upstream testNumberShow suite (test/Test/Main.purs), which asserts the PureScript formats.

Fix needs a formatter that adds .0 for integral finite numbers and maps inf/nan to Infinity/-Infinity/NaN (mirroring the upstream JS show). Found while reviving the prelude test suite (closes-with-credit of #2 by @UnrelatedString).

Activity

  1. self-assigned this
    on Jun 14, 2026
  2. Unisay commented on Jun 15, 2026

    @Unisay
    CollaboratorAuthor

    Fixed in v7.3.0: showNumberImpl emits NaN/Infinity/-Infinity and a trailing .0 on integral Numbers. Verified under Lua 5.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions