module Steep module Diagnostic module Ruby type location = Parser::Source::Range | RBS::Location[untyped, untyped] class Base include Helper attr_reader node: Parser::AST::Node? attr_reader location: location? def initialize: (node: Parser::AST::Node?, ?location: location?) -> void def header_line: () -> String def detail_lines: () -> String? def diagnostic_code: () -> ::String end interface _DiagnosticWithResult def result: () -> Subtyping::Result::Base end module ResultPrinter : _DiagnosticWithResult def relation_message: (Subtyping::Relation[untyped] relation) -> String? def detail_lines: () -> String? end module ResultPrinter2 : _DiagnosticWithResult def result_line: (Subtyping::Result::t result) -> String? def detail_lines: () -> String? end class IncompatibleAssignment < Base attr_reader lhs_type: untyped attr_reader rhs_type: untyped attr_reader result: untyped include ResultPrinter def initialize: (node: untyped, lhs_type: untyped, rhs_type: untyped, result: untyped) -> void def header_line: () -> ::String end class UnexpectedPositionalArgument < Base # Node of argument attr_reader node (): Parser::AST::Node attr_reader params: Interface::Function::Params def initialize: (node: Parser::AST::Node, params: Interface::Function::Params) -> void def header_line: () -> String end class InsufficientPositionalArguments < Base # Send/csend node for method calls without blocks # block/numblock node for method calls with blocks attr_reader node (): Parser::AST::Node attr_reader params: Interface::Function::Params def initialize: (node: Parser::AST::Node, params: Interface::Function::Params) -> void def header_line: () -> String end class UnexpectedKeywordArgument < Base # pair/kwsplat node attr_reader node (): Parser::AST::Node attr_reader params: Interface::Function::Params def initialize: (node: Parser::AST::Node, params: Interface::Function::Params) -> void def header_line: () -> String end class InsufficientKeywordArguments < Base # Send/csend node for method calls without blocks # block/numblock node for method calls with blocks attr_reader node (): Parser::AST::Node attr_reader params: Interface::Function::Params attr_reader missing_keywords: Array[Symbol] def initialize: (node: Parser::AST::Node, params: Interface::Function::Params, missing_keywords: Array[Symbol]) -> void def header_line: () -> String end class UnresolvedOverloading < Base attr_reader node: untyped attr_reader receiver_type: untyped attr_reader method_name: untyped attr_reader method_types: untyped def initialize: (node: untyped, receiver_type: untyped, method_name: untyped, method_types: untyped) -> void def header_line: () -> ::String def detail_lines: () -> untyped end class ArgumentTypeMismatch < Base attr_reader node (): Parser::AST::Node attr_reader expected: AST::Types::t attr_reader actual: AST::Types::t attr_reader result: Subtyping::Result::t include ResultPrinter def initialize: (node: Parser::AST::Node, expected: AST::Types::t, actual: AST::Types::t, result: Subtyping::Result::t) -> void def header_line: () -> ::String end class NoMethod < Base attr_reader type: AST::Types::t attr_reader method: Symbol def initialize: (node: Parser::AST::Node, type: AST::Types::t, method: Symbol) -> void def header_line: () -> ::String end class ReturnTypeMismatch < Base attr_reader expected: untyped attr_reader actual: untyped attr_reader result: untyped include ResultPrinter def initialize: (node: untyped, expected: untyped, actual: untyped, result: untyped) -> void def header_line: () -> ::String end # Setter method, which has a name ending with `=`, returns different type from the method type # # ```ruby # class Foo # # Assume `name=` has method type of `(String) -> String` # def name=(value) # return if value.empty? # @value = value # end # end # ``` # # This is a special diagnostic for setter methods because the return value is not used with ordinal call syntax. # class SetterReturnTypeMismatch < Base attr_reader expected: AST::Types::t attr_reader actual: AST::Types::t attr_reader result: Subtyping::Result::Base attr_reader method_name: Symbol include ResultPrinter def initialize: (node: Parser::AST::Node, method_name: Symbol, expected: AST::Types::t, actual: AST::Types::t, result: Subtyping::Result::Base) -> void def header_line: () -> String end class UnexpectedBlockGiven < Base attr_reader method_type: untyped def initialize: (node: untyped, method_type: untyped) -> void def header_line: () -> "The method cannot be called with a block" end class RequiredBlockMissing < Base attr_reader method_type: untyped def initialize: (node: untyped, method_type: untyped) -> void def header_line: () -> "The method cannot be called without a block" end class BlockTypeMismatch < Base attr_reader expected: untyped attr_reader actual: untyped attr_reader result: untyped include ResultPrinter def initialize: (node: untyped, expected: untyped, actual: untyped, result: untyped) -> void def header_line: () -> ::String end class BlockBodyTypeMismatch < Base attr_reader expected: untyped attr_reader actual: untyped attr_reader result: untyped include ResultPrinter def initialize: (node: untyped, expected: untyped, actual: untyped, result: untyped) -> void def header_line: () -> ::String end class BreakTypeMismatch < Base attr_reader expected: untyped attr_reader actual: untyped attr_reader result: untyped include ResultPrinter def initialize: (node: untyped, expected: untyped, actual: untyped, result: untyped) -> void def header_line: () -> ::String end class ImplicitBreakValueMismatch < Base attr_reader jump_type: untyped attr_reader result: untyped include ResultPrinter def initialize: (node: untyped, jump_type: untyped, result: untyped) -> void def header_line: () -> ::String end class UnexpectedJump < Base def header_line: () -> "Cannot jump from here" end class UnexpectedJumpValue < Base def header_line: () -> ::String end class MethodArityMismatch < Base attr_reader method_type: untyped def initialize: (node: untyped, method_type: untyped) -> void def header_line: () -> ::String end class MethodParameterMismatch < Base attr_reader method_param: untyped attr_reader method_type: untyped def initialize: (method_param: untyped, method_type: untyped) -> void def header_line: () -> ::String end class DifferentMethodParameterKind < Base attr_reader method_param: untyped attr_reader method_type: untyped def initialize: (method_param: untyped, method_type: untyped) -> void def header_line: () -> ::String end class IncompatibleMethodTypeAnnotation < Base attr_reader interface_method: untyped attr_reader annotation_method: untyped attr_reader result: untyped include ResultPrinter def initialize: (node: untyped, interface_method: untyped, annotation_method: untyped, result: untyped) -> void end class MethodReturnTypeAnnotationMismatch < Base attr_reader method_type: untyped attr_reader annotation_type: untyped attr_reader result: untyped include ResultPrinter def initialize: (node: untyped, method_type: untyped, annotation_type: untyped, result: untyped) -> void def header_line: () -> ::String end class MethodBodyTypeMismatch < Base attr_reader expected: untyped attr_reader actual: untyped attr_reader result: untyped include ResultPrinter def initialize: (node: untyped, expected: untyped, actual: untyped, result: untyped) -> void def header_line: () -> ::String end # Setter method, which has a name ending with `=`, has different type from the method type # # ```ruby # class Foo # # Assume `name=` has method type of `(String) -> String` # def name=(value) # @value = value # value.strip! # end # end # ``` # # This is a special diagnostic for setter methods because the return value is not used with ordinal call syntax. # class SetterBodyTypeMismatch < Base attr_reader expected: AST::Types::t attr_reader actual: AST::Types::t attr_reader result: Subtyping::Result::Base attr_reader method_name: Symbol include ResultPrinter def initialize: (node: Parser::AST::Node & Parser::AST::_DefNode, expected: AST::Types::t, actual: AST::Types::t, result: Subtyping::Result::Base, method_name: Symbol) -> void def header_line: () -> String end class UnexpectedYield < Base def header_line: () -> "No block given for `yield`" end class UnexpectedSuper < Base attr_reader method: Symbol? def initialize: (node: Parser::AST::Node, method: Symbol?) -> void def header_line: () -> ::String end class MethodDefinitionMissing < Base attr_reader module_name: untyped attr_reader kind: untyped attr_reader missing_method: untyped def initialize: (node: untyped, module_name: untyped, kind: untyped, missing_method: untyped) -> void def header_line: () -> ::String end class UnexpectedDynamicMethod < Base attr_reader module_name: untyped attr_reader method_name: untyped def initialize: (node: untyped, module_name: untyped, method_name: untyped) -> void def header_line: () -> ::String end class UnknownConstant < Base attr_reader name: untyped attr_reader kind: untyped def initialize: (node: untyped, name: untyped) -> void def class!: () -> self def module!: () -> self def header_line: () -> ::String end class UnknownInstanceVariable < Base attr_reader name: Symbol def initialize: (node: Parser::AST::Node, name: Symbol) -> void def header_line: () -> ::String end class UnknownGlobalVariable < Base attr_reader name: untyped def initialize: (node: untyped, name: untyped) -> void def header_line: () -> ::String end class FallbackAny < Base def initialize: (node: untyped) -> void def header_line: () -> "Cannot detect the type of the expression" end class UnsatisfiableConstraint < Base attr_reader method_type: untyped attr_reader var: untyped attr_reader sub_type: untyped attr_reader super_type: untyped attr_reader result: untyped def initialize: (node: untyped, method_type: untyped, var: untyped, sub_type: untyped, super_type: untyped, result: untyped) -> void include ResultPrinter def header_line: () -> ::String end class IncompatibleAnnotation < Base attr_reader result: Subtyping::Result::Base attr_reader relation: Subtyping::Relation[untyped] attr_reader var_name: Symbol def initialize: (node: Parser::AST::Node, var_name: Symbol, result: Subtyping::Result::Base, relation: Subtyping::Relation[untyped]) -> void include ResultPrinter def header_line: () -> ::String end class IncompatibleTypeCase < Base attr_reader var_name: untyped attr_reader result: untyped attr_reader relation: untyped def initialize: (node: untyped, var_name: untyped, result: untyped, relation: untyped) -> void include ResultPrinter def header_line: () -> ::String end class UnreachableBranch < Base def header_line: () -> String end # The branch is unreachable, but not `bot` type # # We often have `else` branch to make the code more defensive: # # ```ruby # case value # when Integer # # ... # when String # # ... # else # raise "Cannot happen!" # end # ``` # # This diagnostic allows writing `raise` or `return`, by checking the type of the branch body is `bot` or not. # class UnreachableValueBranch < Base attr_reader type: AST::Types::t def initialize: (node: Parser::AST::Node, type: AST::Types::t, ?location: location) -> void def header_line: () -> String end class UnexpectedSplat < Base attr_reader type: untyped def initialize: (node: untyped, type: untyped) -> void def header_line: () -> "Hash splat is given with object other than `Hash[X, Y]`" end class ProcTypeExpected < Base attr_reader type: untyped def initialize: (node: untyped, type: untyped) -> void def header_line: () -> ::String end # The `#to_ary` of RHS of multiple assignment is called, but returns not tuple nor Array. # # ```ruby # a, b = foo() # ^^^^^ # ``` # class MultipleAssignmentConversionError < Base attr_reader original_type: AST::Types::t attr_reader returned_type: AST::Types::t def initialize: (node: Parser::AST::Node, original_type: AST::Types::t, returned_type: AST::Types::t) -> void def header_line: () -> ::String end class UnsupportedSyntax < Base attr_reader message: untyped def initialize: (node: untyped, ?message: untyped?) -> void def header_line: () -> (untyped | ::String) end class UnexpectedError < Base attr_reader message: untyped attr_reader error: untyped def initialize: (node: untyped, error: untyped) -> void def header_line: () -> ::String end class SyntaxError < Base attr_reader message: untyped def initialize: (message: untyped, location: untyped) -> void def header_line: () -> ::String end class FalseAssertion < Base attr_reader assertion_type: AST::Types::t attr_reader node_type: AST::Types::t def initialize: (node: Parser::AST::Node, assertion_type: AST::Types::t, node_type: AST::Types::t) -> void def header_line: () -> String end class UnexpectedTypeArgument < Base attr_reader type_arg: AST::Types::t attr_reader method_type: Interface::MethodType def node: () -> nil def initialize: (type_arg: AST::Types::t, method_type: Interface::MethodType) -> void def header_line: () -> String end class InsufficientTypeArgument < Base attr_reader type_args: Array[AST::Types::t] attr_reader method_type: Interface::MethodType def initialize: (node: Parser::AST::Node, type_args: Array[AST::Types::t], method_type: Interface::MethodType) -> void def header_line: () -> String end class TypeArgumentMismatchError < Base attr_reader type_argument: AST::Types::t attr_reader type_parameter: Interface::TypeParam attr_reader result: Subtyping::Result::Base include ResultPrinter def node: () -> nil def initialize: (type_arg: AST::Types::t, type_param: Interface::TypeParam, result: Subtyping::Result::Base) -> void def header_line: () -> String end # Type hint is given to a proc/lambda but it was ignored # # 1. Because the hint is incompatible to `::Proc` type # 2. More than one *proc type* is included in the hint # class ProcHintIgnored < Base attr_reader hint_type: AST::Types::t def initialize: (hint_type: AST::Types::t, node: Parser::AST::Node) -> void end # RBS embedded in the Ruby code has validation error # class RBSError < Base attr_reader error: Signature::Base def initialize: (error: Signature::Base, node: Parser::AST::Node, location: location) -> void end # Argument forwarding `...` cannot be done safely, because of # # 1. The arguments are incompatible, or # 2. The blocks are incompatible # class IncompatibleArgumentForwarding < Base attr_reader method_name: Symbol attr_reader params_pair: [Interface::Function::Params, Interface::Function::Params]? attr_reader block_pair: [Interface::Block?, Interface::Block?]? attr_reader result: Subtyping::Result::Base include ResultPrinter2 # One of `params_pair:` or `block_pair:` is specified where the first object is of the source method (`#foo`) and the second value is of the target method (`#bar`) # # ```ruby # def foo(...) # bar(...) # end # ``` # def initialize: (node: Parser::AST::Node, method_name: Symbol, params_pair: [Interface::Function::Params, Interface::Function::Params], result: Subtyping::Result::Base) -> void | (node: Parser::AST::Node, method_name: Symbol, block_pair: [Interface::Block?, Interface::Block?], result: Subtyping::Result::Base) -> void def header_line: () -> String end ALL: Array[singleton(Base)] type template = Hash[singleton(Base), LSPFormatter::severity] self.@all_error: template? def self.all_error: () -> template self.@default: template? def self.default: () -> template self.@strict: template? def self.strict: () -> template self.@lenient: template? def self.lenient: () -> template self.@silent: template? def self.silent: () -> template end end end