Steps to reproduce:
1. Place Vehicle Wagon.
2. Use winch to put Tank on Vehicle Wagon.
3. Turn on cheat mode.
4. Use pipette tool (Q) on loaded Vehicle Wagon. Cursor is given another Vehicle Wagon with tank already loaded.
5. Place new Vehicle Wagon with Tank loaded.
6. Mine new Vehicle Wagon. Instead of producing a new tank, game crashes with message:
Error while running event VehicleWagon2::on_pre_player_mined_item (ID 11)
VehicleWagon2/control.lua:429: attempt to index field '?' (a nil value)
stack traceback:
VehicleWagon2/control.lua:429: in function <VehicleWagon2/control.lua:425>
I believe the correct fix is to detect when pipette is used on loaded Vehicle Wagons and substitute an unloaded wagon (in both cheat mode and normal). I just figured this out for Multiple Unit Train Control, so I'm happy to help you with it if you want.