Skip to content
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

activesupport: Update the type of Array.wrap #688

Merged
merged 2 commits into from
Oct 10, 2024

Commits on Oct 8, 2024

  1. activesupport: Update the type of Array.wrap

    At present, `Array.wrap` will be return an empty tuple for untyped value
    because it matches to the first method_type: `(nil) -> []`.
    
    In the type world, the behavior of an empty tuple is different from an
    empty array.  For example, calling a enumerable method will cause type
    an error:
    
    ```
    app/app.rb:18:28: [error] Type `bot` does not have method `to_s`
    │ Diagnostic ID: Ruby::NoMethod
    │
    └ Array.wrap(foo).map { |e| e.to_s }
                                  ~~~~
    
    ```
    
    This changes the return type of `Array.wrap` for nil value to
    `Array[untyped]`.
    
    refs: ruby#683
    tk0miya committed Oct 8, 2024
    Configuration menu
    Copy the full SHA
    3f48ea5 View commit details
    Browse the repository at this point in the history

Commits on Oct 10, 2024

  1. activesupport: Update the type of Array.wrap

    this also changes the case of `[T] (T ele) -> [T]` to `-> Array[T]`
    tk0miya committed Oct 10, 2024
    Configuration menu
    Copy the full SHA
    b9e7d7f View commit details
    Browse the repository at this point in the history