Exception: RBS::RecursiveAncestorError
- Inherits:
-
StandardError
- Object
- StandardError
- RBS::RecursiveAncestorError
- Defined in:
- lib/rbs/errors.rb
Instance Attribute Summary collapse
-
#ancestors ⇒ Object
readonly
Returns the value of attribute ancestors.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(ancestors:, location:) ⇒ RecursiveAncestorError
constructor
A new instance of RecursiveAncestorError.
Constructor Details
#initialize(ancestors:, location:) ⇒ RecursiveAncestorError
Returns a new instance of RecursiveAncestorError.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/rbs/errors.rb', line 70 def initialize(ancestors:, location:) last = case last = ancestors.last when Definition::Ancestor::Singleton "singleton(#{last.name})" when Definition::Ancestor::Instance if last.args.empty? last.name.to_s else "#{last.name}[#{last.args.join(", ")}]" end end super "#{Location.to_string location}: Detected recursive ancestors: #{last}" end |
Instance Attribute Details
#ancestors ⇒ Object (readonly)
Returns the value of attribute ancestors.
67 68 69 |
# File 'lib/rbs/errors.rb', line 67 def ancestors @ancestors end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
68 69 70 |
# File 'lib/rbs/errors.rb', line 68 def location @location end |
Class Method Details
.check!(self_ancestor, ancestors:, location:) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/rbs/errors.rb', line 85 def self.check!(self_ancestor, ancestors:, location:) case self_ancestor when Definition::Ancestor::Instance if ancestors.any? {|a| a.is_a?(Definition::Ancestor::Instance) && a.name == self_ancestor.name } raise new(ancestors: ancestors + [self_ancestor], location: location) end when Definition::Ancestor::Singleton if ancestors.include?(self_ancestor) raise new(ancestors: ancestors + [self_ancestor], location: location) end end end |