Incorrect array signature for `.new` in ActiveRecord model
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 38/100
Research direction
Start by reviewing the linked Shopify/tapioca pull request, especially the referenced diff near line 223, and reproduce the reported Payment.new([]) behavior. Trace how that behavior is reflected in the generated signature. Done means the generated .new signature no longer advertises array attributes or an array return for this case.
Written by the indexing model from the issue text.
Description
An incorrect signature is being generated for the .new method in an ActiveRecord model.
Even though the .new method does not support arrays, this signature is nevertheless being generated:
sig do
params(
attributes: T::Array[T.untyped],
block: T.nilable(T.proc.params(object: ::Payment).void)
).returns(T::Array[::Payment])
end
This is despite arrays not being supported in the .new method:
[1] > Payment.new([])
ArgumentError: When assigning attributes, you must pass a hash as an argument, Array passed.
Suspect commit: https://github.com/Shopify/tapioca/pull/1946/files#diff-ccd1794e49448cc1badb48d2a32af60d5fcd47336d00a484fbf474ebf79b6789R223
- Dominant language
- Ruby
- Stars
- 873
- Forks
- 164
- Avg merge
- 4d 27m
- Merged PRs (30d)
- 9
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Shopify/tapioca
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
bug
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 58/100
Similar issues
-
user-reported
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Kong/developer.konghq.com#7316 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
TheOdinProject/curriculum#31408 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
notch8/utk_knapsack#148 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
Homebrew/homebrew-cask#288729 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100