clay: enforce referential transparency on labels
|= [bel=@tas aey=(unit aeon)]
^+ ..park
=/ yon ?~(aey let.dom u.aey)
+ =/ yen (~(get by lab.dom) bel) :: existing aeon?
+ :: no existing aeon is bound to this label
+ ::
+ ?~ yen
=. lab.dom (~(put by lab.dom) bel yon)
..park
+ :: an aeon is bound to this label,
+ :: but it is the same as the existing one, so we no-op
+ ::
+ ?: =(u.yen yon)
+ ~& "clay: tried to rebind existing label {<bel>} to equivalent aeon {<yon>}"
+ ..park
+ :: an existing aeon bound to the label
+ :: that is distinct from the requested one.
+ :: rewriting would violate referential transparency
+ ::
+ ~| %tried-to-rewrite-existing-label
+ ~& "requested aeon: {<yon>}, existing aeon: {<u.yen>}"
+ !!
::
:: Porcelain commit
::
