Skip to content

formatIntegral broken on negative minBound #150

@mikeplus64

Description

@mikeplus64

Quick bug: formatIntegral is broken when given minBound for whatever integral type. This is because for integer types like Int8, with a range (minBound,maxBound) = (-127,128), the abs of its minBound doesn't fit in the type. The actual result abs (-127 :: Int8) gives is -127. Thus this breaks formatIntegral which calls showInt which requires a non-negative input.

Bug is hereish:

splitSign :: (Num b, Ord b) => b -> (Sign, b)

In base, show @Int8 first marshals the input with fromIntegral :: Int8 -> Int. For Int, they special case minBound.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions