Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000072Core InformRules and rulebookspublic2010-06-19 05:532010-10-28 00:32
Assigned Tograham 
Platformx86OSWindowsOS VersionVista
Product Version6E59 
Target VersionFixed in Version6E72 
Summary0000072: Block-type values produced by rulebooks are not handled correctly
DescriptionThe example source results in a run-time error:

*** Deep copy failed: source empty ***
Minimal Source Text To Reproduce
Home is a room.

Scribbling is a rulebook producing an indexed text.

When play begins: let T be the indexed text produced by the
scribbling rulebook.
Additional InformationI'm a little mystified by the interface to value-producing
rulebooks. They can succeed and produce a value, or they
can fail without producing one, but how is the caller
supposed to know if the rulebook succeeded or failed? One
would have to run it twice, it seems -- once to determine
success and then again to get the value if there was one.

Anyway, I suppose the rulebook here should have produced
a default value to avoid this sort of thing.
TagsNo tags attached.
Effect(serious/mild) Game compiles but misbehaves
Attached Files

- Relationships
related to 0000071closedgraham Phrases to invoke value-producing rulebooks don't work with certain kinds of values 

-  Notes
jmcgrew (administrator)
2010-06-19 13:22

The cat behavior example in the manual (18.12) checks for success by testing whether the return value is the expected type, but that only works for objects. Instead, you can just ask whether the rule succeeded:

    let N be the number produced by the foo rulebook;
    if the rule succeeded, say "Success: [N].";
    otherwise say "Failure."
jmcgrew (administrator)
2010-06-19 13:28

Even when the rulebook does produce a value, it's not returned correctly when the value is of a block type.

Home is a room.

Foo is a rulebook producing an indexed text.
Foo: rule succeeds with result "hello".

When play begins:
let N be the indexed text produced by the foo rulebook;
if the rule succeeded, say "Success: [N].";
otherwise say "Failure."

This displays "Success: ." instead of "Success: hello."

Home is a room.

Foo is a rulebook producing a stored action.
Foo: rule succeeds with result the action of taking inventory.

When play begins:
let N be the stored action produced by the foo rulebook;
if the rule succeeded, say "Success: [N].";
otherwise say "Failure."

This displays "Success: waiting." instead of "Success: taking inventory."

I couldn't test with lists because of the parsing issues noted elsewhere.
fundin (reporter)
2010-06-20 06:24

Thanks for the advice RE: success/failure. That also makes it clear that a default return value is needed, since this coding pattern won't work for block type values if the rulebook just returns zero.
graham (administrator)
2010-06-20 07:17

The idea is that if a rulebook fails, or otherwise does not produce a value, then the value is produced is the default for that kind. I seem to have forgotten to implement this in 6E59; I have done so now.
fundin (reporter)
2010-07-05 06:51

Default return values are now handled correctly, but explicit ones like those in Jesse's two examples still don't work. They result in a run-time error:

*** Deep copy failed: types mismatch ***
EmacsUser (manager)
2010-07-07 11:23

Confirmed with the source text from 0000072:0000058.
graham (administrator)
2010-09-26 06:08

This was really two different issues, which is why it's now being resolved for the second time. The second problem was essentially that, although rulebooks did produce block values successfully, they were being deallocated before they could be used, with dead pointers then being used in subsequent code. This is now fixed.

- Issue History
Date Modified Username Field Change
2010-06-19 05:53 fundin New Issue
2010-06-19 10:52 jmcgrew Status new => acknowledged
2010-06-19 13:22 jmcgrew Note Added: 0000057
2010-06-19 13:22 jmcgrew Status acknowledged => confirmed
2010-06-19 13:28 jmcgrew Note Added: 0000058
2010-06-19 13:28 jmcgrew Summary Errors caused by value-producing rulebooks that fail to produce values => Block-type values produced by rulebooks are not handled correctly
2010-06-19 13:29 jmcgrew Relationship added related to 0000071
2010-06-19 13:37 jmcgrew Severity mild => serious
2010-06-20 06:24 fundin Note Added: 0000077
2010-06-20 07:17 graham Note Added: 0000078
2010-06-20 07:17 graham Status confirmed => resolved
2010-06-20 07:17 graham Resolution open => fixed
2010-06-20 07:17 graham Assigned To => graham
2010-06-30 18:07 jmcgrew Fixed in Version => 6E72
2010-07-01 23:07 jmcgrew Status resolved => closed
2010-07-05 06:51 fundin Note Added: 0000238
2010-07-05 06:51 fundin Status closed => feedback
2010-07-05 06:51 fundin Resolution fixed => reopened
2010-07-06 13:18 jmcgrew Status feedback => acknowledged
2010-07-07 11:23 EmacsUser Note Added: 0000259
2010-07-07 11:23 EmacsUser Status acknowledged => confirmed
2010-09-26 06:08 graham Note Added: 0000586
2010-09-26 06:08 graham Status confirmed => resolved
2010-09-26 06:08 graham Resolution reopened => fixed
2010-10-28 00:32 jmcgrew Status resolved => closed

Copyright © 2000 - 2010 MantisBT Group
Powered by Mantis Bugtracker