lib/rbs/errors.rb in rbs-1.8.1 vs lib/rbs/errors.rb in rbs-2.0.0.pre1

- old
+ new

@@ -12,15 +12,15 @@ "#{type_name}#{separator}#{method_name}" end end - class ErrorBase < StandardError; end - class LoadingError < ErrorBase; end - class DefinitionError < ErrorBase; end + class BaseError < StandardError; end + class LoadingError < BaseError; end + class DefinitionError < BaseError; end - class ParsingError < ErrorBase + class ParsingError < BaseError attr_reader :location attr_reader :error_message attr_reader :token_type def initialize(location, error_message, token_type) @@ -103,11 +103,11 @@ end end end end - class NoTypeFoundError < ErrorBase + class NoTypeFoundError < BaseError attr_reader :type_name attr_reader :location def initialize(type_name:, location:) @type_name = type_name @@ -414,11 +414,11 @@ raise end end end - class RecursiveTypeAliasError < LoadingError + class RecursiveTypeAliasError < BaseError attr_reader :alias_names attr_reader :location def initialize(alias_names:, location:) @alias_names = alias_names @@ -430,17 +430,30 @@ def name @alias_names.map(&:name).join(', ') end end - class NonregularTypeAliasError < LoadingError + class NonregularTypeAliasError < BaseError attr_reader :diagnostic attr_reader :location def initialize(diagnostic:, location:) @diagnostic = diagnostic @location = location super "#{Location.to_string location}: Nonregular generic type alias is prohibited: #{diagnostic.type_name}, #{diagnostic.nonregular_type}" + end + end + + class CyclicTypeParameterBound < BaseError + attr_reader :params, :type_name, :method_name, :location + + def initialize(type_name:, method_name:, params:, location:) + @type_name = type_name + @method_name = method_name + @params = params + @location = location + + super "#{Location.to_string(location)}: Cyclic type parameter bound is prohibited" end end end