Class: Rigor::RbsExtended::AssertEffect

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

Overview

Returned for ‘assert` / `assert-if-true` / `assert-if-false`. `condition` is one of:

  • ‘:always` — refines `target` at the call’s

    post-scope unconditionally
    (`assert`).
    
  • ‘:if_truthy_return` — refines `target` only when the

    call's return value is observed
    as truthy (currently: as the
    predicate of a subsequent
    `if` / `unless`).
    
  • ‘:if_falsey_return` — symmetric for falsey.

‘negative` mirrors `PredicateEffect`: true when the directive uses `~ClassName` syntax.

Instance Method Summary collapse

Instance Method Details

#always?Boolean

Returns:

  • (Boolean)


103
# File 'lib/rigor/rbs_extended.rb', line 103

def always? = condition == :always

#if_falsey_return?Boolean

Returns:

  • (Boolean)


105
# File 'lib/rigor/rbs_extended.rb', line 105

def if_falsey_return? = condition == :if_falsey_return

#if_truthy_return?Boolean

Returns:

  • (Boolean)


104
# File 'lib/rigor/rbs_extended.rb', line 104

def if_truthy_return? = condition == :if_truthy_return

#negative?Boolean

Returns:

  • (Boolean)


106
# File 'lib/rigor/rbs_extended.rb', line 106

def negative? = negative == true

#refinement?Boolean

Returns:

  • (Boolean)


107
# File 'lib/rigor/rbs_extended.rb', line 107

def refinement? = !refinement_type.nil?

#to_factObject

ADR-7 § “Slice 4-A” canonical translation. Same shape as ‘PredicateEffect#to_fact`; the `condition` field (`:always` / `:if_truthy_return` / `:if_falsey_return`) routes which slot the resulting fact lands in at the `read_flow_contribution` boundary, but does not surface on the Fact itself.



115
116
117
118
119
120
121
122
# File 'lib/rigor/rbs_extended.rb', line 115

def to_fact
  FlowContribution::Fact.new(
    target_kind: target_kind,
    target_name: target_name,
    type: refinement_type || Rigor::Type::Combinator.nominal_of(class_name),
    negative: negative == true
  )
end