mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-09-20 15:08:34 +03:00
clay: enforce referential transparency on labels
This commit is contained in:
parent
25ce97cade
commit
17751e7890
@ -1450,9 +1450,26 @@
|
||||
++ label
|
||||
|= [bel=@tas aey=(unit aeon)]
|
||||
^+ ..park
|
||||
=/ yon ?~(aey let.dom u.aey)
|
||||
=. lab.dom (~(put by lab.dom) bel yon)
|
||||
..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
|
||||
::
|
||||
|
Loading…
Reference in New Issue
Block a user