Module: Ryac::RenameInvariants
- Included in:
- LocalScopes
- Defined in:
- lib/ryac/analysis/scope_management.rb,
sig/ryac/analysis/scope_management.rbs
Overview
Two different variables of one scope collapsing into one name silently
changes what the code computes, and the result still parses — the
self-hosted minifier once emitted def c(a) = c(a) || d(a) this way. Every
scope mapping passes through here before it is used, so a collision fails
the run instead of shipping.
Its own module so LocalScopes can include just this: including AnalysisPhases would graft dozens of phase methods onto it as ancestors, which under self-hosting entangles its rename groups with the mixin's.
Instance Method Summary collapse
Instance Method Details
#verify_injective!(mapping, scope_label) ⇒ void
This method returns an undefined value.
15 16 17 18 19 20 21 22 23 |
# File 'lib/ryac/analysis/scope_management.rb', line 15 def verify_injective!(mapping, scope_label) return if mapping.size < 2 collisions = mapping.group_by { |_, short| short } .filter_map { |short, pairs| [short, pairs.map(&:first)] if pairs.size > 1 } #: Array[[String, Array[Symbol]]] return if collisions.empty? raise Pipeline::RenameCollisionError.new(scope_label, collisions) end |