Class: Rigor::Type::Dynamic

Inherits:
Object
  • Object
show all
Defined in:
lib/rigor/type/dynamic.rb

Overview

The dynamic-origin wrapper: marks values whose type came from an unchecked source. Carries a static facet that records the analyzer’s best static knowledge. See docs/type-specification/value-lattice.md for the algebra and docs/type-specification/special-types.md for the untyped/Dynamic relationship.

Construct via Rigor::Type::Combinator.dynamic(static_facet).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(static_facet) ⇒ Dynamic

Returns a new instance of Dynamic.



17
18
19
20
# File 'lib/rigor/type/dynamic.rb', line 17

def initialize(static_facet)
  @static_facet = static_facet
  freeze
end

Instance Attribute Details

#static_facetObject (readonly)

Returns the value of attribute static_facet.



15
16
17
# File 'lib/rigor/type/dynamic.rb', line 15

def static_facet
  @static_facet
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



46
47
48
# File 'lib/rigor/type/dynamic.rb', line 46

def ==(other)
  other.is_a?(Dynamic) && static_facet == other.static_facet
end

#accepts(other, mode: :gradual) ⇒ Object



42
43
44
# File 'lib/rigor/type/dynamic.rb', line 42

def accepts(other, mode: :gradual)
  Inference::Acceptance.accepts(self, other, mode: mode)
end

#botObject



34
35
36
# File 'lib/rigor/type/dynamic.rb', line 34

def bot
  Trinary.no
end

#describe(verbosity = :short) ⇒ Object



22
23
24
# File 'lib/rigor/type/dynamic.rb', line 22

def describe(verbosity = :short)
  "Dynamic[#{static_facet.describe(verbosity)}]"
end

#dynamicObject



38
39
40
# File 'lib/rigor/type/dynamic.rb', line 38

def dynamic
  Trinary.yes
end

#erase_to_rbsObject



26
27
28
# File 'lib/rigor/type/dynamic.rb', line 26

def erase_to_rbs
  "untyped"
end

#hashObject



51
52
53
# File 'lib/rigor/type/dynamic.rb', line 51

def hash
  [Dynamic, static_facet].hash
end

#inspectObject



55
56
57
# File 'lib/rigor/type/dynamic.rb', line 55

def inspect
  "#<Rigor::Type::Dynamic #{describe(:short)}>"
end

#topObject



30
31
32
# File 'lib/rigor/type/dynamic.rb', line 30

def top
  Trinary.no
end