Skip to content

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

@Unisay

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).

Metadata

Metadata

Assignees

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