Exception: RBS::InvalidTypeApplicationError
- Inherits:
-
DefinitionError
- Object
- StandardError
- BaseError
- DefinitionError
- RBS::InvalidTypeApplicationError
- Defined in:
- lib/rbs/errors.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#type_name ⇒ Object
readonly
Returns the value of attribute type_name.
-
#type_params ⇒ Object
readonly
Returns the value of attribute type_params.
Class Method Summary collapse
- .check!(type_name:, args:, params:, location:) ⇒ Object
- .check2!(env:, type_name:, args:, location:) ⇒ Object
Instance Method Summary collapse
-
#initialize(type_name:, args:, params:, location:) ⇒ InvalidTypeApplicationError
constructor
A new instance of InvalidTypeApplicationError.
Constructor Details
#initialize(type_name:, args:, params:, location:) ⇒ InvalidTypeApplicationError
Returns a new instance of InvalidTypeApplicationError.
74 75 76 77 78 79 80 81 |
# File 'lib/rbs/errors.rb', line 74 def initialize(type_name:, args:, params:, location:) @type_name = type_name @args = args @type_params = params @params = params.map(&:name) @location = location super "#{Location.to_string location}: #{type_name} expects parameters [#{params.join(", ")}], but given args [#{args.join(", ")}]" end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
69 70 71 |
# File 'lib/rbs/errors.rb', line 69 def args @args end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
72 73 74 |
# File 'lib/rbs/errors.rb', line 72 def location @location end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
70 71 72 |
# File 'lib/rbs/errors.rb', line 70 def params @params end |
#type_name ⇒ Object (readonly)
Returns the value of attribute type_name.
68 69 70 |
# File 'lib/rbs/errors.rb', line 68 def type_name @type_name end |
#type_params ⇒ Object (readonly)
Returns the value of attribute type_params.
71 72 73 |
# File 'lib/rbs/errors.rb', line 71 def type_params @type_params end |
Class Method Details
.check!(type_name:, args:, params:, location:) ⇒ Object
83 84 85 86 87 88 89 90 |
# File 'lib/rbs/errors.rb', line 83 def self.check!(type_name:, args:, params:, location:) min_arity = params.count { _1.default_type.nil? } max_arity = params.size unless min_arity <= args.size && args.size <= max_arity raise new(type_name: type_name, args: args, params: params, location: location) end end |
.check2!(env:, type_name:, args:, location:) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/rbs/errors.rb', line 92 def self.check2!(env:, type_name:, args:, location:) params = case when type_name.class? decl = env.normalized_module_class_entry(type_name) or raise decl.type_params when type_name.interface? env.interface_decls.fetch(type_name).decl.type_params when type_name.alias? env.type_alias_decls.fetch(type_name).decl.type_params else raise end check!(type_name: type_name, args: args, params: params, location: location) end |