Class: Jade::Frontend::TypeChecking::VarGen
- Inherits:
-
Object
- Object
- Jade::Frontend::TypeChecking::VarGen
- Defined in:
- lib/jade/frontend/type_checking/var_gen.rb
Overview
Type-var ids must be unique across every scheme that ever flows through unification. Per-instance counters made cross-module imports fragile: a fresh id from one module could equal a quantified id from another, aliasing them through Substitution.apply. A class-level counter makes collisions impossible by construction.
Class Attribute Summary collapse
-
.counter ⇒ Object
Returns the value of attribute counter.
Instance Method Summary collapse
Class Attribute Details
.counter ⇒ Object
Returns the value of attribute counter.
14 15 16 |
# File 'lib/jade/frontend/type_checking/var_gen.rb', line 14 def counter @counter end |
Instance Method Details
#fresh(name = nil) ⇒ Object
21 22 23 24 |
# File 'lib/jade/frontend/type_checking/var_gen.rb', line 21 def fresh(name = nil) fresh_id .then { Type.var(it, name) } end |
#fresh_id ⇒ Object
17 18 19 |
# File 'lib/jade/frontend/type_checking/var_gen.rb', line 17 def fresh_id "t#{self.class.counter += 1}" end |