Class: Steep::Diagnostic::Ruby::IncompatibleAssignment
- Includes:
- ResultPrinter
- Defined in:
- lib/steep/diagnostic/ruby.rb
Instance Attribute Summary collapse
-
#lhs_type ⇒ Object
readonly
Returns the value of attribute lhs_type.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#rhs_type ⇒ Object
readonly
Returns the value of attribute rhs_type.
Attributes inherited from Base
Instance Method Summary collapse
- #header_line ⇒ Object
-
#initialize(node:, lhs_type:, rhs_type:, result:) ⇒ IncompatibleAssignment
constructor
A new instance of IncompatibleAssignment.
Methods included from ResultPrinter
#detail_lines, #relation_message
Methods inherited from Base
#detail_lines, #diagnostic_code
Methods included from Helper
Constructor Details
#initialize(node:, lhs_type:, rhs_type:, result:) ⇒ IncompatibleAssignment
Returns a new instance of IncompatibleAssignment.
71 72 73 74 75 76 |
# File 'lib/steep/diagnostic/ruby.rb', line 71 def initialize(node:, lhs_type:, rhs_type:, result:) super(node: node) @lhs_type = lhs_type @rhs_type = rhs_type @result = result end |
Instance Attribute Details
#lhs_type ⇒ Object (readonly)
Returns the value of attribute lhs_type.
65 66 67 |
# File 'lib/steep/diagnostic/ruby.rb', line 65 def lhs_type @lhs_type end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
67 68 69 |
# File 'lib/steep/diagnostic/ruby.rb', line 67 def result @result end |
#rhs_type ⇒ Object (readonly)
Returns the value of attribute rhs_type.
66 67 68 |
# File 'lib/steep/diagnostic/ruby.rb', line 66 def rhs_type @rhs_type end |
Instance Method Details
#header_line ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/steep/diagnostic/ruby.rb', line 78 def header_line node = node() or raise element = case node.type when :ivasgn, :lvasgn, :gvasgn, :cvasgn "a variable" when :casgn "a constant" else "an expression" end "Cannot assign a value of type `#{rhs_type}` to #{element} of type `#{lhs_type}`" end |