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
Reporterfundin 
Assigned Tograham 
PrioritynormalSeverityseriousReproducibilityalways
StatusclosedResolutionfixed 
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
(0000057)
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."
(0000058)
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.

<code>
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."
</code>

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

<code>
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."
</code>

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

I couldn't test with lists because of the parsing issues noted elsewhere.
(0000077)
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.
(0000078)
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.
(0000238)
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 ***
(0000259)
EmacsUser (manager)
2010-07-07 11:23

Confirmed with the source text from 0000072:0000058.
(0000586)
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