Stack traces in TADS aren't great

I’m not using Windows so I can’t use the Workbench. Or, rather, don’t want to use Wine just for it.) But that shouldn’t matter because a stack trace should tell me all I need. So I’m going through the Tour Guide and I got to a point where moving in a direction lead to this:

Nowhere in there is there a reference to my actual code. Exactly the opposite of what a full stack trace should be. Yes, I realize I know exactly where to go in this case but that’s also because I’m building up the example slowly with a minimum of supporting elements.

The code that is in place when the error is generated is this:

class Cabin : ShipboardRoom, Room;

class DarkCabin : Cabin
  brightness = 0

greatCabin : Cabin 'Great Cabin'
  "description here"

  up = cabinSteps
  fore = bulkheadDoor

+ bulkheadDoor : HiddenDoor 
  'bulkhead door/doorway/opening' 'bulkhead door'
  "description here"

  destination = crewQuarters

crewQuarters : DarkCabin 'Crew Quarters'

  aft = greatCabin

Going “fore” from the greatCabin is causing this. And I do have the button from the code in place that opens the hidden door. (This is from the HiddenDoor section of the Tour Guide.

So it’s entirely unclear what object is trying to reference something that is nil.

Well, the given excerpt of your code is missing the cabinSteps item. If what is shown is the entire code, there is your nil object reference.

Stack trace really only shows a codepath where the mistake caused an error in a running program (the place where the mistake demonstrated itself) which is not guaranteed to be the same place where a programmer made a mistake. Try to lool at it from this perspective - lots of your actual code is actually not a code, but rather a declarations of data. Lots of work in writing TADS program is assigning values to different properties which are manipulated from the library code. So it is not uncommon to see a stack trace where only library code is involved. This is quite common not only in interactive fiction but also in general programming using complex frameworks, I see similar stack traces all the time when writing web applications at work.

Using debugger to look to the contents of variables to see what objects or what properties was manipulated is really useful, but you can workaround on Linux or Mac by copy pasting the method from the library where the error demonstrated itself into your own source code and adding debugging commands such as printing object name just before problem arises. Use the modify keyword to override library class and paste problematic method here.

I agree (partly) on the stack trace but you are dealing with a situation that is occurring at runtime due to – I’m willing to bet – how objects are being linked.up I’ve seen this before with some classes I’ve taught. Nine times out of ten it’s because some object is missing a location.

You mentioned the HiddenDoor part of the Tour Guide. Have you implemented all of the objects there? The hold and the ladder? In particular look to see if you haven’t defined a location for one of those objects.

For example, say you have this:

holdLadderUp : StairwayUp -> holdLadderDown 'ladder' 'ladder';

instead of:

+ holdLadderUp : StairwayUp -> holdLadderDown 'ladder' 'ladder';

If the + property isn’t in place (or a @ notation), it will give the exact stack trace you are talking about. The same would apply for holdLadderDown. I believe it has to be one of those things because those are the only elements that come into play when you are going to the crewQuarters. Specifically, if one of the connectors, which point to each other, doesn’t have a location, that’s what the nil reference likely is and that will happen the moment you enter the room.

Thanks. That was it. I didn’t have one of the connectors with a location.