Created
May 28, 2023 08:53
-
-
Save tk0miya/2f271a3478fcd8b82c85c7fde96a3057 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/rbs/prototype/rb.rb b/lib/rbs/prototype/rb.rb | |
index 646ed909..3667d7dc 100644 | |
--- a/lib/rbs/prototype/rb.rb | |
+++ b/lib/rbs/prototype/rb.rb | |
@@ -5,11 +5,11 @@ module RBS | |
class RB | |
include Helpers | |
- Context = _ = Struct.new(:module_function, :singleton, :namespace, keyword_init: true) do | |
+ Context = _ = Struct.new(:module_function, :singleton, :namespace, :in_block, keyword_init: true) do | |
# @implements Context | |
- def self.initial(namespace: Namespace.root) | |
- self.new(module_function: false, singleton: false, namespace: namespace) | |
+ def self.initial(namespace: Namespace.root, in_block: false) | |
+ self.new(module_function: false, singleton: false, namespace: namespace, in_block: in_block) | |
end | |
def method_kind | |
@@ -213,6 +213,8 @@ module RBS | |
case node.children[0] | |
when :include | |
+ return if context.in_block | |
+ | |
args.each do |arg| | |
if (name = const_to_name(arg, context: context)) | |
klass = context.singleton ? AST::Members::Extend : AST::Members::Include | |
@@ -352,7 +354,8 @@ module RBS | |
when :refine | |
# ignore | |
else | |
- process_children(node, decls: decls, comments: comments, context: context) | |
+ new_ctx = Context.initial(namespace: context.namespace, in_block: true) | |
+ process_children(node, decls: decls, comments: comments, context: new_ctx) | |
end | |
when :CDECL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment