[Vm-dev] FilePlugin argument checking - primitiveFailed vs PrimErrBadArgument
Alistair Grant
akgrant0710 at gmail.com
Thu Mar 1 19:21:28 UTC 2018
Hi Everyone,
I'm currently extending FilePlugin to allow files to be opened using
either a file descriptor or FILE*. If you're interested more details
at:
Original PR: https://github.com/pharo-project/pharo-vm/pull/108
Updated PR: https://github.com/pharo-project/pharo-vm/pull/142
While tidying up the argument checking I noticed that FilePlugin has as
part of #primitiveFileOpen:
namePointer := interpreterProxy stackValue: 1.
(interpreterProxy isBytes: namePointer)
ifFalse: [^ interpreterProxy primitiveFail].
My understanding is that this is bad practice as #primitiveFail won't
correctly retry if the argument is a forwarder. So it should be:
namePointer := interpreterProxy stackValue: 1.
(interpreterProxy isBytes: namePointer)
ifFalse: [^ interpreterProxy primitiveFailFor: PrimErrBadArgument].
Can someone confirm that I'm not misunderstanding, and I'll go through
and check FilePlugin further.
Thanks,
Alistair
More information about the Vm-dev
mailing list