I can confirm this. The definition of gVerifyIobj is brittle, always requiring an object reference to be returned. At first I thought maybe it should return a dummy object if gTentativeIobj failed, but then the use of gVerifyIobj would be inconsistent if a player tried
where, especially if it is possible that this situation can happen at any time other than right after game launch, the dummy object could potentially pass verify for an action that clearly expects a sim object…
Should a dummy gCommand be in place at the beginning of the game so gTentativeIobj is never nil or length 0?
Note that if you launch a (skeletal) game and begin with
>put hat in me
What do you want to put it in?
there is no error. It’s like it takes the first mention of an iobj to get it set.
I don’t think the problem is with gVerifyIobj. Although it’s the attempt to evaluate it that causes the run-time error, in a way this could be seen as a good thing, since it’s calling attention to problems that lie elsewhere.
One problem is that that the parser is interpreting PUT CLOAK as an incomplete PUT IN command, which I don’t think it should do (why PUT IN rather than PUT ON or PUT UNDER or PUT BEHIND?). So one response here would be to tell the player they need to specify where they want to put the hat. This is relatively easy to do (define a PutVague Verbule with a corresponding Put Action which is ruled out accordingly at the verify stage).
But this doesn’t address the problem of why the parser is calling the verify routine that triggers the runtime error in the one case (the initial PUT HAT) and not the other (PUT HAT following PUT HAT IN ME), so I need to dig a bit deeper to figure out what’s happening here.
Part of what’s happening is that following PUT HAT IN ME gIobj is still set to me when the command PUT HAT is parsed, so that gVerifyIobj evaluates to me and the runtime error triggered by trying to evaluate gTentatativeIobj is never triggered, but that all raises further questions I need to delve into.
EDIT: A tentative set of fixes fix is to change a line in the selectObjects(cmd) method in parser.t (so that verify methods that cause the error have less reason to be called, to change the definition of the gVerifyDobj/gVerifyIobj macros so that they evaluate to nil in cases where the runtime error would otherwise occur, and adding protective code to statements where this might cause a nil object reference error (by using if(gVerifyIobj && …)). I’ll mull over it a bit more before uploading these changes to GitHub.
A couple of notes: I mistyped when I said the response was
What do you want to put it in?
In fact, it said
Where do you want to put it?
as it should.
Furthermore, it seems to be the case that once an iobj is referenced, it doesn’t matter how many intervening commands there are, the next time you try ‘put cloak’, there will be no error.
Could this not possibly be fixed by giving gTentativeIobj some kind of starting value? It seems then that the behavior would be from the start as it is after I typed ‘put hat in me’.
It seems that it would be a shame to change gVerifyIobj (if indeed this is the only instance where gTentativeIobj comes up empty), because of how much verb code relies on the definition as it is. Also there may be users who are used to using gVerifyIobj without having to do the && check and might get confused.
Just submitting some thoughts… I know you’ll do what you think best with it.