Parameter type includes values assigned via `Hash#[]=` on local variable
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 45/100
Piste de recherche
Exécutez d’abord bin/typeprof sur reproduce.rb et comparez la signature générée avec le RBS attendu. Suivez ensuite le traitement de Hash#[]= dans TypeProf, puis utilisez la commande Action Pack et les entrées route_set.rb, formatter.rb et routing_test.rb pour vérifier que les types des paramètres n’accumulent plus les valeurs affectées ni les structures Hash récursives.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Steps to reproduce
Analyze the following file with TypeProf.
def foo(options)
options[:name] = "str"
nil
end
foo(Hash.new)
Expected behavior
class Object
def foo: (Hash[untyped, untyped]) -> nil
end
Parameter types should only reflect the types passed from call sites, not values assigned inside the method.
Actual behavior
$ bin/typeprof reproduce.rb
# TypeProf 0.31.1
# reproduce.rb
class Object
def foo: (Hash[:name, String]) -> nil
end
System configuration
Ruby version: ruby 4.0.0 (2025-12-25 revision 553f1675f3) +PRISM [arm64-darwin25]
TypeProf version: 753de9b8501f4f7c509e605ea9c9982efa8fc311
Real-world use cases
I noticed this issue when analyzing Action Pack with TypeProf.
The minimum steps required to actually analyze Action Pack are as follows:
$ bin/typeprof tmp/rails/actionpack/test/controller/routing_test.rb \
tmp/rails/actionpack/lib/action_dispatch/routing/route_set.rb \
tmp/rails/actionpack/lib/action_dispatch/journey/formatter.rb > ap.rbs
$ cat ap.rbs | grep url_for | wc -c
13936
$ cat ap.rbs | grep url_for
def url_for: (Hash[:_recall | :action | :anchor | :controller | :domain | :foo | :format | :host | :id | :name | :only_path | :original_script_name | :params | :password | :path | :path_params | :person | :port | :protocol | :script_name | :subdomain | :tld_length | :trailing_slash | :use_route | :user | Range[Integer], (Hash[:_recall | :action | :anchor | :controller | :domain | :foo | :format | :host | :id | :name | :only_path | :original_script_name | :params | :password | :path | :path_params | :person | :port | :protocol | :script_name | :subdomain | :tld_length | :trailing_slash | :use_route | :user | Range[Integer], (Hash[:_recall | :action | :anchor | :controller | :domain | :foo | :format | :host | :id | :name | :only_path | :original_script_name | :params | :password | :path | :path_params | :person | :port | :protocol | :script_name | :subdomain | :tld_length | :trailing_slash | :use_route | :user | Range[Integer], (Hash[:_recall | :action | :anchor | :controller | :domain | :foo | :format | :host | :id | :name | :only_path | :original_script_name | :params | :password | :path | :path_params | :person | :port | :protocol | :script_name | :subdomain | :tld_length | :trailing_slash | :use_route | :user | Range[Integer], (Hash[:_recall | :action | :anchor | :controller | :domain | :foo | :format | :host | :id | :name | :only_path | :original_script_name | :params | :password | :path | :path_params | :person | :port | :protocol | :script_name | :subdomain | :tld_length | :trailing_slash | :use_route | :user | Range[Integer], (Hash[:_recall | :action | :anchor | :controller | :domain | :foo | :format | :host | :id | :name | :only_path | :original_script_name | :params | :password | :path | :path_params | :person | :port | :protocol | :script_name | :subdomain | :tld_length | :trailing_slash | :use_route | :user | Range[Integer], (Hash[:_recall | :action | :anchor | :controller | :domain | :foo | :format | :host | :id | :name | :only_path | :original_script_name | :params | :password | :path | :path_params | :person | :port | :protocol | :script_name | :subdomain | :tld_length | :trailing_slash | :use_route | :user | Range[Integer], (Hash[:_recall | :action | :anchor | :controller | :domain | :foo | :format | :host | :id | :name | :only_path | :original_script_name | :params | :password | :path | :path_params | :person | :port | :protocol | :script_name | :subdomain | :tld_length | :trailing_slash | :use_route | :user | Range[Integer], String] | Hash[:_recall | :action | :anchor | :controller | :domain | :foo | :format | :host | :id | :name | :only_path | :original_script_name | :params | :password | :path | :path_params | :person | :port | :protocol | :script_name | :subdomain | :tld_length | :trailing_slash | :use_route | :user | Range[Integer], untyped] | String)?] | Hash[:_recall | :action | :anchor | :controller | :domain | :foo | :format | :host | :id | :name | :only_path | :original_script_name | :params | :password | :path | :path_params | :person | :port | :protocol | :script_name | :subdomain | :tld_length | :trailing_slash | :use_route | :user | Range[Integer], String] | Hash[:_recall | :action | :anchor | :controller | :domain | :foo | :format | :host | :id | :name | :only_path | :original_script_name | :params | :password | ...(omitted
The parameter type contains a recursive structure such as Hash[:_recall | ..., Hash[:_recall | ..., Hash[:_recall, ...].
I have identified the cause of this as Hash#[]=.
- Langage dominant
- Ruby
- Étoiles
- 833
- Forks
- 99
- Merge moyen
- 3 j 17 h
- PR mergées (30 j)
- 21
Préparer son environnement
Nous n'avons pas encore vérifié les fichiers d'installation de ce projet. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de ruby/typeprof
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 28/100
-
invalid option: --initOuverte
Difficulté 3/5 1-2 jours Accessibilité débutants 25/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 38/100
-
Difficulté 3/5 1-2 jours Accessibilité débutants 30/100
-
Difficulté 3/5 1-2 jours Accessibilité débutants 35/100
Toutes les issues de ruby/typeprof
Issues similaires
-
DB上でコメント本文がNULLを許容しているOuverteバグ
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
-
security
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
IBM/ai-security-baseline#25 ·
-
security
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Les mainteneurs répondent en général sous 1 jour
-
Mend: dependency security vulnerability
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Les mainteneurs répondent en général sous 1 jour