Skip to content

Deprecate redundant global functions and add Swift standard library redundancy tests - #61

Merged
ctreffs merged 3 commits into
masterfrom
redundant-api
Aug 24, 2026
Merged

Deprecate redundant global functions and add Swift standard library redundancy tests#61
ctreffs merged 3 commits into
masterfrom
redundant-api

Conversation

@ctreffs

@ctreffs ctreffs commented Aug 24, 2026

Copy link
Copy Markdown
Member

Summary

This PR deprecates global scalar math functions (abs, min, max) that conflict with the Swift Standard Library and introduces a dedicated test suite (SwiftStandardLibraryRedundancyTests) to verify equivalence between FirebladeMath functions and native Swift / platform math APIs across all supported platforms.

What Changed

  • Deprecations & Disfavored Overloads:
    • Annotated abs(_ x: Float) / abs(_ x: Double) with @_disfavoredOverload and @available(*, deprecated, message: "Use Swift.abs(_:) or x.magnitude instead.", renamed: "Swift.abs").
    • Annotated min(_ x: Float, _ y: Float) / min(_ x: Double, _ y: Double) with @_disfavoredOverload and @available(*, deprecated, message: "Use Swift.min(_:_:) instead.", renamed: "Swift.min").
    • Annotated max(_ x: Float, _ y: Float) / max(_ x: Double, _ y: Double) with @_disfavoredOverload and @available(*, deprecated, message: "Use Swift.max(_:_:) instead.", renamed: "Swift.max").
  • Internal Cleanup:
    • Updated internal helper calls in clamp.swift and fract.swift to explicitly invoke Swift.min / Swift.max.
  • Redundancy Test Suite:
    • Added Tests/FirebladeMathTests/SwiftStandardLibraryRedundancyTests.swift verifying equivalence for:
      • Core global functions (abs, min, max)
      • FloatingPoint protocol methods (squareRoot, rounded, init(signOf:magnitudeOf:), truncatingRemainder, classification checks)
      • SIMD vector operations (Array(simd), SIMD.clamped, (v1 * v2).sum() dot product, isNaN)
      • Standard math overlays (trigonometric, hyperbolic, exponential, logarithmic)

Why

  • Prevents ambiguity and overload collision with Swift.abs, Swift.min, and Swift.max.
  • Ensures zero-warning builds when treating warnings as errors (-Xswiftc -warnings-as-errors).
  • Provides comprehensive CI test coverage verifying functional parity with the Swift Standard Library across all target platforms.

Testing Steps

  1. Run swift build -Xswiftc -warnings-as-errors
  2. Run swift test -Xswiftc -warnings-as-errors (All 278 tests across 22 suites pass)

Risk of Regression

  • Low: Non-breaking deprecation warning annotations with @_disfavoredOverload preserving existing call sites while steering callers towards Swift standard library primitives.

@ctreffs ctreffs changed the title test: add test suite verifying Swift standard library redundancies Deprecate redundant global functions and add Swift standard library redundancy tests Aug 24, 2026
@ctreffs
ctreffs marked this pull request as ready for review August 24, 2026 09:26
@ctreffs
ctreffs merged commit 168c806 into master Aug 24, 2026
12 checks passed
@ctreffs
ctreffs deleted the redundant-api branch August 24, 2026 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant