Class: BELParser::Language::Semantics::SemanticsTypeWarning

Inherits:
SemanticsWarning show all
Defined in:
lib/bel_parser/language/semantics_ast_warnings.rb,
lib/bel_parser/language/semantics_type_warning.rb

Instance Attribute Summary collapse

Attributes inherited from SemanticsResult

#expression_node, #specification

Instance Method Summary collapse

Methods inherited from SemanticsWarning

#failure?, #success?

Methods inherited from SemanticsResult

#failure?, #msg, #success?

Constructor Details

#initialize(expression_node, expected_type, actual_type, spec) ⇒ SemanticsTypeWarning

Returns a new instance of SemanticsTypeWarning.



36
37
38
39
40
# File 'lib/bel_parser/language/semantics_ast_warnings.rb', line 36

def initialize(expression_node, spec, expected, actual)
  super(expression_node, spec)
  @expected_type = expected.ast_type
  @actual_type   = actual.type
end

Instance Attribute Details

#actual_typeObject (readonly)

Returns the value of attribute actual_type.



34
35
36
# File 'lib/bel_parser/language/semantics_ast_warnings.rb', line 34

def actual_type
  @actual_type
end

#expected_typeObject (readonly)

Returns the value of attribute expected_type.



34
35
36
# File 'lib/bel_parser/language/semantics_ast_warnings.rb', line 34

def expected_type
  @expected_type
end

Instance Method Details

#to_sObject



42
43
44
# File 'lib/bel_parser/language/semantics_ast_warnings.rb', line 42

def to_s
  %(Expected #{expected_type} type, but saw #{actual_type} type.)
end