Skip to content

fix(library/math): guards against infinite operands in greatestCommonDivisor #538

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

bjacobgordon
Copy link
Collaborator

No description provided.

@bjacobgordon bjacobgordon self-assigned this Jul 17, 2025
@github-actions github-actions bot added the fix label Jul 17, 2025
bjacobgordon added a commit that referenced this pull request Jul 17, 2025
…nstructable" (#540)

- while `NonActionableError.throw` is the recommended way of constructing and propagating an instance, there's no inherent danger in directly constructing
- unblocks #538 
  - a common way to detect constructors is to check for conformance to an interface like:
    ```typescript
    interface DirectlyConstructable {
      new: (...parameters: any[]): any;
    }
    ```
    - useful in scenarios where constructors are passed to implementations that "reconstruct" an instance
  - any class that implements `DirectlyConstructable` will inherently conform to:
    ```typescript
    interface InstanceMatchable {
      [Symbol.hasInstance]: (...parameters: any[]): boolean;
    }
    ```
    - objects that conform to _this_ interface are guaranteed to be compatible with the `instanceOf` operator
  - a problem arises when a class regulates constructor usage via static factories
    - on the one hand, it's no longer "directly constructable"
    - but on the other, the class can still "have instances"
    - so, if the goal is to use `instanceOf` and not necessarily "reconstruct" an instance, then conformance to `DirectlyConstructable` is needlessly restrictive.
@bjacobgordon bjacobgordon force-pushed the fix(library/math)--guards-against-infinite-operands-in-`greatestCommonDivisor` branch from ec25be4 to d81afe9 Compare July 17, 2025 14:59
bjacobgordon added a commit that referenced this pull request Jul 17, 2025
@bjacobgordon bjacobgordon force-pushed the fix(library/math)--guards-against-infinite-operands-in-`greatestCommonDivisor` branch from d81afe9 to eb542af Compare July 17, 2025 15:12
@bjacobgordon bjacobgordon merged commit 3ffff81 into nod-ai:integration Jul 17, 2025
3 checks passed
@bjacobgordon bjacobgordon deleted the fix(library/math)--guards-against-infinite-operands-in-`greatestCommonDivisor` branch July 17, 2025 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant