Exception: RBS::TypeParamDefaultReferenceError

Inherits:
DefinitionError show all
Includes:
DetailedMessageable
Defined in:
lib/rbs/errors.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DetailedMessageable

#detailed_message

Constructor Details

#initialize(type_param, location:) ⇒ TypeParamDefaultReferenceError

Returns a new instance of TypeParamDefaultReferenceError.



586
587
588
589
590
# File 'lib/rbs/errors.rb', line 586

def initialize(type_param, location:)
  super "#{Location.to_string(location)}: the default of #{type_param.name} cannot include optional type parameter"
  @location = location
  @type_param = type_param
end

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



584
585
586
# File 'lib/rbs/errors.rb', line 584

def location
  @location
end

#type_paramObject (readonly)

Returns the value of attribute type_param.



583
584
585
# File 'lib/rbs/errors.rb', line 583

def type_param
  @type_param
end

Class Method Details

.check!(type_params) ⇒ Object



592
593
594
595
596
597
598
# File 'lib/rbs/errors.rb', line 592

def self.check!(type_params)
  if errors = AST::TypeParam.validate(type_params)
    error = errors[0] or raise
    error.default_type or raise
    raise new(error, location: error.default_type.location)
  end
end