From c16897f80d0cb18c59285c5fd85fa12dea623c41 Mon Sep 17 00:00:00 2001 From: ksss Date: Sun, 1 Aug 2021 21:34:49 +0900 Subject: [PATCH 1/2] Should quote var name --- lib/rbs_rails/active_record.rb | 8 ++++---- test/app/app/models/user.rb | 2 +- test/rbs_rails/active_record_test.rb | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/rbs_rails/active_record.rb b/lib/rbs_rails/active_record.rb index b7f3591..478c103 100644 --- a/lib/rbs_rails/active_record.rb +++ b/lib/rbs_rails/active_record.rb @@ -260,17 +260,17 @@ def reload_#{a.name}: () -> #{type_optional} args_node.children.each do |node| case node.type when :arg - res << "untyped #{node.children[0]}" + res << "untyped `#{node.children[0]}`" when :optarg - res << "?untyped #{node.children[0]}" + res << "?untyped `#{node.children[0]}`" when :kwarg res << "#{node.children[0]}: untyped" when :kwoptarg res << "?#{node.children[0]}: untyped" when :restarg - res << "*untyped #{node.children[0]}" + res << "*untyped `#{node.children[0]}`" when :kwrestarg - res << "**untyped #{node.children[0]}" + res << "**untyped `#{node.children[0]}`" when :blockarg block = " { (*untyped) -> untyped }" else diff --git a/test/app/app/models/user.rb b/test/app/app/models/user.rb index 4952878..3d609ca 100644 --- a/test/app/app/models/user.rb +++ b/test/app/app/models/user.rb @@ -1,5 +1,5 @@ class User < ApplicationRecord - scope :all_kind_args, -> (a, m = 1, n = 1, *rest, x, k: 1, **kwrest, &blk) { all } + scope :all_kind_args, -> (type, m = 1, n = 1, *rest, x, k: 1,**untyped, &blk) { all } scope :no_arg, -> () { all } has_and_belongs_to_many :blogs diff --git a/test/rbs_rails/active_record_test.rb b/test/rbs_rails/active_record_test.rb index fadb5d9..bbdddaa 100644 --- a/test/rbs_rails/active_record_test.rb +++ b/test/rbs_rails/active_record_test.rb @@ -106,14 +106,14 @@ def will_save_change_to_updated_at?: () -> bool def restore_updated_at!: () -> void def clear_updated_at_change: () -> void - def self.all_kind_args: (untyped a, ?untyped m, ?untyped n, *untyped rest, untyped x, ?k: untyped, **untyped kwrest) { (*untyped) -> untyped } -> ActiveRecord_Relation + def self.all_kind_args: (untyped `type`, ?untyped m, ?untyped n, *untyped rest, untyped x, ?k: untyped, **untyped `untyped`) { (*untyped) -> untyped } -> ActiveRecord_Relation def self.no_arg: () -> ActiveRecord_Relation class ActiveRecord_Relation < ActiveRecord::Relation include _ActiveRecord_Relation[User, Integer] include Enumerable[User] - def all_kind_args: (untyped a, ?untyped m, ?untyped n, *untyped rest, untyped x, ?k: untyped, **untyped kwrest) { (*untyped) -> untyped } -> ActiveRecord_Relation + def all_kind_args: (untyped `type`, ?untyped m, ?untyped n, *untyped rest, untyped x, ?k: untyped, **untyped `untyped`) { (*untyped) -> untyped } -> ActiveRecord_Relation def no_arg: () -> ActiveRecord_Relation end @@ -124,7 +124,7 @@ class ActiveRecord_Associations_CollectionProxy < ActiveRecord::Associations::Co end def app_dir - File.expand_path('../app', __dir__) + File.expand_path('../app', __dir__) end def setup! From 08d5575919e21e9f8a0ab96c7de2e6a7ffd22217 Mon Sep 17 00:00:00 2001 From: ksss Date: Mon, 2 Aug 2021 16:12:58 +0900 Subject: [PATCH 2/2] Support ruby-head https://github.com/rails/globalid/pull/132 --- test/app/Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/app/Gemfile.lock b/test/app/Gemfile.lock index ba9d3c2..ca5d988 100644 --- a/test/app/Gemfile.lock +++ b/test/app/Gemfile.lock @@ -74,8 +74,8 @@ GEM concurrent-ruby (1.1.8) crass (1.0.6) erubi (1.10.0) - globalid (0.4.2) - activesupport (>= 4.2.0) + globalid (0.5.1) + activesupport (>= 5.0) i18n (1.8.10) concurrent-ruby (~> 1.0) loofah (2.9.1)