Class: Rigor::Type::Dynamic

Inherits:
Object
  • Object
show all
Includes:
AcceptanceRouter, ValueSemantics
Defined in:
lib/rigor/type/dynamic.rb,
sig/rigor/type.rbs

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

Methods included from ValueSemantics

included

Constructor Details

#initialize(static_facet) ⇒ Dynamic

Returns a new instance of Dynamic.

Parameters:

  • static_facet (Type::t)


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_facetType::t (readonly)

Returns the value of attribute static_facet.

Returns:

  • (Type::t)


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

def static_facet
  @static_facet
end

Instance Method Details

#==Boolean

Parameters:

  • other (Object)

Returns:

  • (Boolean)


65
# File 'sig/rigor/type.rbs', line 65

def ==: (untyped other) -> bool

#acceptsAcceptsResult

Parameters:

  • other (Type::t)
  • mode: (accepts_mode)

Returns:



64
# File 'sig/rigor/type.rbs', line 64

def accepts: (Type::t other, ?mode: accepts_mode) -> AcceptsResult

#botTrinary

Returns:



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

def bot
  Trinary.no
end

#describe(verbosity = :short) ⇒ String

Parameters:

  • verbosity (Symbol) (defaults to: :short)

Returns:

  • (String)


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

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

#dynamicTrinary

Returns:



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

def dynamic
  Trinary.yes
end

#erase_to_rbs"untyped"

Returns:

  • ("untyped")


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

def erase_to_rbs
  "untyped"
end

#hashInteger

Returns:

  • (Integer)


66
# File 'sig/rigor/type.rbs', line 66

def hash: () -> Integer

#inspectString

Returns:

  • (String)


48
49
50
# File 'lib/rigor/type/dynamic.rb', line 48

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

#topTrinary

Returns:



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

def top
  Trinary.no
end