[Vm-dev] Bug in #instVarAt:put: for read-only objects
tim Rowledge
tim at rowledge.org
Fri Jan 5 19:45:21 UTC 2018
> On 05-01-2018, at 9:17 AM, Eliot Miranda <eliot.miranda at gmail.com> wrote:
>
>
> The index and bounds validation should also occur, probably first. So something like
>
> Object>>instVarAt: index put: anObject
> <primitive: 174 error: ec>
> (index isInteger
> and: [index between: 1 and: self class instSize + self basicSize]) ifFalse:
> [self badIndexError: index].
> self isReadOnlyObject ifTrue:
> [^(NoModificationError for: self atInstVar: index with: anObject) signal].
> self primitiveFailed
Surely the no-modification check ought to come first since the index is completely irrelevant in that case?
And obviously we ought to be doing cleverer things with the returned error codes; we could avoid the all the tests here since the prim already provides error codes for bad argument (the index isInteger test), bad index (index bounds) and bad rcvr (immutability - though might we not want a specific error here instead?) I know, I know; somebody has to find the time to do the work.
tim
--
tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
Never forget: 2 + 2 = 5 for extremely large values of 2.
More information about the Vm-dev
mailing list