Class: Laser::Analysis::Bindings::ConstantBinding
- Inherits:
-
Base
- Object
- Base
- Laser::Analysis::Bindings::ConstantBinding
- Defined in:
- lib/laser/analysis/bindings.rb
Overview
Constants have slightly different properties in their bindings: They shouldn't be rebound. However.... Ruby allows it. It prints a warning when the rebinding happens, but we should be able to detect this statically. Oh, and they can't be bound inside a method. That too is easily detected statically.
Instance Attribute Summary
Attributes inherited from Base
#annotated_type, #ast_node, #definition, #inferred_type, #name, #self_owner, #uses, #value
Instance Method Summary (collapse)
-
- (Object) bind!(val, force = false)
Require an additional force parameter to rebind a Constant.
Methods inherited from Base
#<=>, #class_used, #deep_dup, #expr_type, #initialize, #initialize_dup_deep, #inspect, #scope, #to_s
Methods included from Comparable
#<, #<=, #==, #>, #>=, #between?, compare_int
Constructor Details
This class inherits a constructor from Laser::Analysis::Bindings::Base
Instance Method Details
- (Object) bind!(val, force = false)
Require an additional force parameter to rebind a Constant. That way, the user can configure whether rebinding counts as a warning or an error.
89 90 91 92 93 94 |
# File 'lib/laser/analysis/bindings.rb', line 89 def bind!(val, force=false) if @value != :uninitialized && !force raise TypeError.new('Cannot rebind a constant binding without const_set') end super(val) end |