Skip to content

Int.construct(from:) can crash instead of return nil #258

Closed
@stephencelis

Description

@stephencelis

While the JSValueCompatible APIs are failable, the underlying conversion of calling SignedInteger.init(_:) and UnsignedInteger.init(_:) directly can crash at runtime if:

  • double.isNan
  • !double.isFinite
  • double > .max || double < .min

Ideally, none of these would crash and return nil instead:

  • Int.construct(from: JSValue.number(.infinity))
  • Int.construct(from: JSValue.number(.nan))
  • Int.construct(from: JSValue.number(numberGreaterThanIntMax)
  • Int.construct(from: JSValue.number(numberLessThanIntMin)

Metadata

Metadata

Assignees

No one assigned

    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