Open
Description
Consider this program:
mutate_methods = (
run = (
mutate_methods methods at:2 put: #a.
self f.
)
f = ( ^#b. )
)
[There is obviously a fragile assumption here that the f
is the second method in methods
, but let's not worry about that for the time being.]
On Java SOM it crashes on the self f
call:
Exception in thread "main" java.lang.ClassCastException: class som.vmobjects.SSymbol cannot be cast to class som.vmobjects.SInvokable (som.vmobjects.SSymbol and som.vmobjects.SInvokable are in unnamed module of loader 'app')
which makes sense. However this seemingly inconsequential variation:
mutate_methods = (
run = (
self f.
mutate_methods methods at:2 put: #a.
self f.
)
f = ( ^#b. )
)
does not crash, presumably because the first self f
call populates an inline cache which is not invalidated when the methods
Array
is mutated.
I assume that this is probably not the intended semantics for this second program (or perhaps it is?), but I'm not sure if e.g. a) SOM should notice the method change b) forbid chnages to the methods
Array
(e.g. via some sort of "this Array
can't be altered?"). Any thoughts?