DavidGriffith / inform6lib

The Inform6 interactive fiction standard library (moved to https://gitlab.com/DavidGriffith/inform6lib)
Other
22 stars 9 forks source link

Multiple groups in item listings #25

Closed DavidGriffith closed 8 years ago

DavidGriffith commented 8 years ago

More from vlaviano:

I've continued working through DM4, and I've encountered an issue related to the exercises in §27 (Listing and grouping objects).

I have a group of Scrabble letters with a list_together routine (DM exercise 67) and a group of identical featureless cubes. The library's item listing code produces a number of errors when these two groups of items coexist either in the same room or in the player's inventory. If they are separated (one group in the room and the other group in the player's inventory) or if only one group is implemented (comment out either of the chunks of code between dashed lines in the test program below), item listing behaves as expected.

Adding a regular item (e.g., Object -> rock "rock" with name 'rock';) doesn't appear to have an impact either way. When the letters and cubes are together, the issue manifests.

Constant Story "MULTIPLE GROUPS IN ITEM LISTINGS";
Constant Headline "^An Interactive Bug Reproduction^";

Include "Parser";
Include "VerbLib";

Object Start_Room "Somewhere"
  with description "You're not sure where you are.",
  has light;

! DM4 Exercise 67
Class Letter
  with name 'letter' 'scrabble' 'piece' 'letters//p' 'pieces//p',
!----------------------
       list_together [;
           if (inventory_stage == 1) {
               print "the letters ";
               c_style = c_style | (ENGLISH_BIT + NOARTICLE_BIT);
               c_style = c_style & ~(NEWLINE_BIT + INDENT_BIT);
           } else {
               print " from a Scrabble set";
           }
       ],
!----------------------
       short_name [;
           if (listing_together ofclass Letter) rfalse;
           print "letter ", (object) self, " from a Scrabble set";
           rtrue;
       ],
       article "the";

Letter -> "X" with name 'x//';
Letter -> "Y" with name 'y//';
Letter -> "Z" with name 'z//';

! Created to test Exercise 66.
Class Cube
  with name 'cube' 'cubes//p' 'featureless' 'white',
       short_name "featureless white cube",
       plural "featureless white cubes"; 

!----------------------
Cube ->;
Cube ->;
Cube ->;
Cube ->;
!----------------------

[ Initialise;
  location = Start_Room;
];

Include "Grammar";
MULTIPLE GROUPS IN ITEM LISTINGS
An Interactive Bug Reproduction
Release 1 / Serial number 160118 / Inform v6.33 Library 6/12-beta1 S

Somewhere
You're not sure where you are.

You can see the letters X, Y and Z from a Scrabble set, four featureless white
cubes,
[** Programming error: tried to find the "sibling" of nothing **]

[** Programming error: tried to find the "sibling" of nothing **]

[** Programming error: tried to find the "sibling" of nothing **]

[Lots of msgs removed for brevity. The upshot being that the library is trying
to operate on nothing while printing the room description.]

>take all letters
letter X from a Scrabble set: Taken.
letter Y from a Scrabble set: Taken.
letter Z from a Scrabble set: Taken.

>i
You're carrying:
the letters Z, Y and X from a Scrabble set

>l

Somewhere
You're not sure where you are.

You can see four featureless white cubes here.

>drop all letters
letter Z from a Scrabble set: Dropped.
letter Y from a Scrabble set: Dropped.
letter X from a Scrabble set: Dropped.

>take all cubes
featureless white cube: Taken.
featureless white cube: Taken.
featureless white cube: Taken.
featureless white cube: Taken.

>i
You're carrying:
four featureless white cubes

>l

Somewhere
You're not sure where you are.

You can see the letters X, Y and Z from a Scrabble set here.

>take all letters
letter X from a Scrabble set: Taken.
letter Y from a Scrabble set: Taken.
letter Z from a Scrabble set: Taken.

>i
You're carrying:
the letters Z, Y and X from a Scrabble set
four featureless white cubes

[** Programming error: tried to find the "sibling" of nothing **]

[** Programming error: tried to find the "sibling" of nothing **]

[** Programming error: tried to find the "sibling" of nothing **]

[Another slew of error messages omitted.]

>l

Somewhere
You're not sure where you are.

>script off

End of transcript.

When the test program is compiled without strict mode (-~S), we get the following more readable summary of errors:

MULTIPLE GROUPS IN ITEM LISTINGS
An Interactive Bug Reproduction
Release 1 / Serial number 160118 / Inform v6.33 Library 6/12-beta1

Somewhere
You're not sure where you are.

You can see the letters X, Y and Z from a Scrabble set, four featureless white
cubes, Warning: @get_sibling called with object 0 (PC = 9c3f) (will ignore
further occurrences)
Warning: @get_prop called with object 0 (PC = a055) (will ignore further
occurrences)
zero Warning: @get_prop_addr called with object 0 (PC = d070) (will ignore
further occurrences)
** Library error 2 (0, 23) **
Warning: @test_attr called with object 0 (PC = a559) (will ignore further
occurrences)
Warning: @get_child called with object 0 (PC = a69e) (will ignore further
occurrences)
and zero ** Library error 2 (0, 23) **
here.

>take all
letter X from a Scrabble set: Taken.
letter Y from a Scrabble set: Taken.
letter Z from a Scrabble set: Taken.
featureless white cube: Taken.
featureless white cube: Taken.
featureless white cube: Taken.
featureless white cube: Taken.

>i
You're carrying:
four featureless white cubes
the letters Z, Y and X from a Scrabble set
two hundred and fifty-five ** Library error 2 (0, 23) **
Warning: @set_attr called with object 0 (PC = a270) (will ignore further
occurrences)

Warning: @clear_attr called with object 0 (PC = a27a) (will ignore further
occurrences)
two hundred and fifty-five ** Library error 2 (0, 23) **

>
DavidGriffith commented 8 years ago

Originally reported at http://www.intfiction.org/forum/viewtopic.php?f=7&t=19461&p=105831#p105707

DavidGriffith commented 8 years ago

http://inform7.com/mantis/view.php?id=1854

DavidGriffith commented 8 years ago

Problems began with cbb8983fca27e313023198e2b60c99afec9f498a

DavidGriffith commented 8 years ago

When compiled to Glulx, the bug causes a segfault.

DavidGriffith commented 8 years ago

Problem appears to be in WriteListR() in verblibm.h

Note how the correct text is this:

You can see the letters X, Y and Z from a Scrabble set and four featureless
white cubes here.

The wrong text is this:

You can see the letters X, Y and Z from a Scrabble set, four featureless
white cubes,
(errors)

Clearly there's a fencepost error.

DavidGriffith commented 8 years ago

senc is being incremented once too many?

DavidGriffith commented 8 years ago

For what it's worth, those two above commits are bad. I managed to delete them from my local repo and force push those changes to Github. You won't be able to get them if you clone this repo, but for some strange reason they still exist on the Github website. A trouble ticket has been filed about this.