Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000324Core InformListspublic2010-10-03 22:192010-10-29 09:02
Reporteralex 
Assigned Tograham 
PrioritynormalSeveritymildReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSMac OS XOS Version
Product Version6E59 
Target VersionFixed in Version6F95 
Summary0000324: Local variables declared in a branch remain in scope after that branch
DescriptionThe code below produces a runtime error:

>[5] z
Time passes.

*** Deep copy failed: destination empty ***
 are pushed down the conveyor belt. The mechanical arm pulls the stuff out of the bin and places it on the conveyor belt.
Minimal Source Text To Reproduce
"Example" by "Cop E. Catter"

[Please bear with me here. This is very large but with any less 
functionality (I think) it would not produce the error. Since this was 
extracted from a work-in-progress, I found it difficult to trim it 
down.]

The recycling plant is a region.

Walkway is in recycling Plant. "You are on a walkway overlooking a huge recycling plant. Below you 
is a hopper. Stretching out to the north of the hopper is a conveyor belt. Over the conveyor belt is 
a giant hammer. To the north of the hammer, the belt goes into a furnace."

A garbage chute and a dial are here. The garbage chute and dial are 
fixed in place. The garbage chute is a container.

After inserting something into the garbage chute:
	say "[The noun] falls into the chute and out of sight.";
	move the noun to the Hopper.

Hopper is below Catwalk. Hopper is in recycling plant. "You are in a large hopper. To the north 
is a conveyor belt heading away. Above the belt is an enormous hammer. You can climb back up to the catwalk 
from here. A mechanical arm is attached to the side of the hopper."

A mechanical arm is here. It is scenery.

Belt is a region in recycling plant.

Rule for printing the name of a room in belt: say "On a Conveyor Belt"

The conveyor belt is a backdrop. It is in Belt.

Belt1 is in belt. Belt1 is north of Hopper. "You are on a conveyor belt. Above you hangs an enormous 
hammer. To the north is a furnace."

Belt2 is in belt. Belt2 is north of belt1. "You are on a conveyor belt. Directly to the north is 
a furnace. There doesn't seem to be any way out of this mess!"

The dial has a number called the setting. The setting of the dial is 
1.

Instead of turning the dial, say "Try setting it to some number."

The description of the dial is "It can be set to any number from one to four. It is currently at 
[setting in words]. Below the dial is some lettering: POUND FREQUENCY."

Instead of setting the dial to:
	if the topic understood includes "[number]":
		if the number understood is greater than 0 and the 
number understood is less than 5:
			if the number understood is the setting of the 
dial:
				say "The dial is already set to [number understood in words].";
			else:
				now the setting of the dial is the 
number understood;
				say "The dial is now set to [number understood in words].";
		else:
			say "The dial can only be set to numbers from one to four.";
	else:
		say "The dial can only be set to numbers from one to four."

Instead of entering the garbage chute:
	say "Whee!";
	move the player to Hopper.

To decide what text is the flattened form of (item - object) (this is 
crushing):
	if the item is a person, decide on "steaks";
	decide on "sheet metal"

Every turn:
	if belt2 contains a portable thing:
		if the player is in belt2 and we are not going south:
			say "[if a portable thing which is not a person is in belt2]Along with [the list of visible portable 
things that are not the player], y[else]Y[end if]ou fall into the furnace.";
			end the story saying "You have died";
			rule fails;
		if in recycling plant, say "[The list of portable things in belt2] fall[if number of portable 
things in belt2 is 1]s[end if] into the furnace. ";
		repeat with item running through portable things in 
belt2:
			if item is not player, remove item from play;
	if the remainder after dividing the turn count by the setting of 
the dial is 0:
		let L be the list of portable things in belt1;
		if the player is in belt1:
			if we are going south:
				remove the player from L;
		if L is empty:
			if in recycling plant, say "The hammer crashes down on empty conveyor belt. ";
		else:
			let T be crushing applied to L;
			if in recycling plant, say "The hammer crashes down on [L with definite articles], flattening 
[if number of entries in L is 1]it[else]them[end if] into [T][unless number of entries in L is 1], respectively[end 
if]. ";
			if the player is listed in L:
				end the story saying "You have died";
				rule fails;
			else:
				if in recycling plant, say "[if number of entries in L is 1]It then crumbles[else]They then 
crumble[end if] to dust. ";
			repeat with item running through L:
				remove item from play;
	else:
		let L be the list of portable things in belt1;
		if we are going south, remove the player from L, if 
present;
		if the player is listed in L:
			remove the player from L;
			if in recycling plant, say "You[if number of things in location is at least 3], along with [L 
with definite articles][end if] are pushed down the conveyor belt. ";
			add the player to L;
		else:
			if in recycling plant:
				if L is non-empty:
					say "[L with definite articles] [if number of entries in L is 1]is[else]are[end if] pushed 
down the conveyor belt. ";
		if L is non-empty:
			repeat with item running through L:
				move item to belt2;
	if Hopper contains a portable thing (called item):
		if in recycling plant, say "The mechanical arm pulls [the item] out of the bin and places [if 
item is the player]you[else]it[end if] on the conveyor belt. ";
		move the item to Belt1;
	if in recycling plant, say line break.

Instead of going south in belt:
	say "You jog down the conveyor belt but are unable to go fast enough to gain any distance in that 
direction."

Rule for printing the name of the player: say "you"

After printing the locale description of a room in recycling plant:
	let L be {hopper, belt1, belt2};
	remove the location from L, if present;
	repeat with item running through L:
		if item is:
			-- hopper:
				if hopper contains something portable, say "The hopper contains [a list of portable things in 
hopper].[paragraph break]";
			-- belt1:
				if a portable thing is in belt1, say "On the belt under the hammer you see [a list of portable 
things in belt1].[paragraph break]";
			-- belt2:
				if a portable thing is in belt2, say "On the belt near the furnace you see [a list of things 
in belt2].[paragraph break]";
	say no line break.

The player carries a thingy, a stuff, a junk, and a whatsit.

Test me with "put thingy in chute/z/put all in chute/set dial to 2/z/z"

Additional Information"When the Deep Copy Failed message pops up, it doesn't produce a runtime error in the Errors pane. Nor does an explanation of what a deep copy is appear anywhere in the documentation. I'd like to know what's going wrong, how I can keep it from going wrong, and why 'move item to belt2' isn't running."
TagsNo tags attached.
Effect(serious/mild) Game compiles but misbehaves
Attached Files

- Relationships

-  Notes
(0000675)
EmacsUser (manager)
2010-10-04 07:30

Reduced:

- - - -
There is a room.

When play begins:
        if zero is one:
                let L be the list of things;
        else:
                let L be the list of things;
                say "[L]"
- - - -

The second let is treated as an assignment to L, because L is considered already declared. Thus,

- - - -
! [2: let l be the list of things]
t_0 = (blockv_stack-->(I7BASPL+0));
BlkValueCopy(t_0, LIST_OF_TY_Desc((blockv_stack-->(I7BASPL+1)), Prop_0, OBJECT_TY) );
- - - -

for the first let, but just

- - - -
! [4: let l be the list of things]
BlkValueCopy(t_0, LIST_OF_TY_Desc((blockv_stack-->(I7BASPL+2)), Prop_1, OBJECT_TY) );
- - - -

for the second. A workaround is to use different names for each list.
(0000676)
graham (administrator)
2010-10-10 02:14

This is now fixed, though it's a slightly traumatic change. The log reads:

The rules on how temporary "let" variables are have been enforced better in this
new build. This does cause some existing source text to fail. For example, in
the example "Nickel and Dimed", previous builds included this:

if the total price of underpayment money is less than the cost:
let the desired bill be the cheapest money which is overpayment;
otherwise:
let the desired bill be the costliest money which is underpayment;
decide on the desired bill.

This is now rejected because "desired bill" is a name given to two different
temporary values, each of which expires at the end of a branch of the "if";
so that nothing called "desired bill" still exists at the "decide on..." line.
While the above source looks (and is) harmless enough, consider this:

if the total price of underpayment money is less than the cost:
let the desired bill be the cheapest money which is overpayment;
decide on the desired bill.

This is clearly unfortunate if the condition fails, as then "desired bill" is
a temporary value never brought into existence at all. Past builds of Inform
would have allowed the usage, giving "desired bill" its default value in that
case (albeit failing badly if the kind was such that no default value existed),
but this was not a good idea. So we are now enforcing the rules more strictly.
The same applies to the branches of an "if X is: ...", too. The relevant
passage in "Nickel and Dimed" now reads:

if the total price of underpayment money is less than the cost:
decide on the cheapest money which is overpayment;
otherwise:
decide on the costliest money which is underpayment.

- Issue History
Date Modified Username Field Change
2010-10-03 22:19 jmcgrew New Issue
2010-10-03 22:20 jmcgrew Status new => confirmed
2010-10-03 22:20 jmcgrew OS => Mac OS X
2010-10-04 07:30 EmacsUser Note Added: 0000675
2010-10-04 07:38 EmacsUser Summary Runtime error "Deep copy failed: destination empty" when printing list => Local variables declared in a branch remain in scope after that branch
2010-10-10 02:14 graham Note Added: 0000676
2010-10-10 02:14 graham Status confirmed => resolved
2010-10-10 02:14 graham Resolution open => fixed
2010-10-10 02:14 graham Assigned To => graham
2010-10-24 12:06 jmcgrew Reporter jmcgrew => email
2010-10-25 21:14 jmcgrew Fixed in Version => 6F95
2010-10-28 00:31 jmcgrew Status resolved => closed
2010-10-29 09:02 jmcgrew Reporter email => alex


Copyright © 2000 - 2010 MantisBT Group
Powered by Mantis Bugtracker