curiousdannii-testing / inform7-imported-bugs

0 stars 0 forks source link

[I7-1766] [Mantis 1802] Rule for printing a parser error does not acknowledge "while <action name>" as part of specificity when choosing best rule? #318

Open curiousdannii-testing opened 2 years ago

curiousdannii-testing commented 2 years ago

Reported by : otistdog

Description :

It looks like the "for printing a parser error" activity should be capable of checking the state of action_to_be (similar to other activities that happen during parsing), but it does not seem to do so in execution of appropriate rules. The generated rulebook specificity listing does not show a higher preference for rules that include a "while " clause vs. those that don't.

In contrast, rules that would require a fully-formed action do seem to be be given higher specificity, even though they will not evaluate as naively expected (similar to other activities that happen during parsing).

Steps to reproduce :

"Test"

Place is a room.

Parser action-to-be is an action name that varies. The parser action-to-be variable translates into I6 as "action_to_be".

Rule for printing a parser error when the latest parser error is the can't see any such thing error:
    say " The what now?"

Rule for printing a parser error while examining when the latest parser error is the can't see any such thing error:
    say "Can't see that thingy, so can't look at it closer (action name version)."

Rule for printing a parser error when the current action is examining something and the latest parser error is the can't see any such thing error:
    say "Can't see that thingy, so can't look at it closer (full action version)." [Note that this rule is acknowledged to have an improper preamble for the activity; see "Additional Information"]

Test me with "x cow".

Additional information :

Output from "test me":
============================
Place

>test me
(Testing.)

>[1] x cow
The what now?
============================

You can see that action_to_be is set in a way valid for comparison. However, the generated I6 includes:

! ----------------------------------------------------------------------------------------------------
! Rules in rulebook: for Printing a parser error (B95_for_printing_a_parser_er)
! ----------------------------------------------------------------------------------------------------
! Rule 1/3 ! Rule for printing a parser error when the current action is examining something and the latest parser error is the can't see any such thing error:
! >>> III - When/while requirement >>>
! Rule 2/3 ! Rule for printing a parser error when the latest parser error is the can't see any such thing error:
! === equally specific with ===
! Rule 3/3 ! Rule for printing a parser error while examining when the latest parser error is the can't see any such thing error:
! ----------------------------------------------------------------------------------------------------

Based on that, it looks like the improper rule requiring a fully-formed action is given highest specificity, while the other two rules are judged equally specific, even though one does actually check for the partial action:

============================
! No specific request
! Rule for printing a parser error when the latest parser error is the can't see any such thing error:
[ R_777 ;
if ((((((etype == I83_can_t_see_any_such_thing))))))

{ ! Runs only while condition holds if (debug_rules) DB_Rule(R_777, 777); ! [1: say ~<action-to-be = [parser action-to-be]> The what now?~] say__p=1;ParaContent(); print " The what now?"; new_line; .L_Say6; .L_SayX6; RulebookSucceeds(); rtrue; }

else if (debug_rules > 1) DB_Rule(R_777, 777, 'context');
rfalse;
];
! No specific request
! Rule for printing a parser error while examining when the latest parser error is the can't see any such thing error:
[ R_778 ;
if (((((((action ==##Examine) && (actor==player) && (self=actor,true) && (((etype == I83_can_t_see_any_such_thing)))))))))

{ ! Runs only while condition holds if (debug_rules) DB_Rule(R_778, 778); ! [1: say ~Can't see that thingy, so can't look at it closer (action name version).~] say__p=1;ParaContent(); print "Can't see that thingy, so can't look at it closer (action name version)."; new_line; .L_Say7; .L_SayX7; RulebookSucceeds(); rtrue; }

else if (debug_rules > 1) DB_Rule(R_778, 778, 'context');
rfalse;
];
============================

Per WWI 18.3, only "the most specific" for rule is selected, which in this case I would think would be the "... while examining..." version. However, this is not the case, even when the improper version evaluating the fully-formed current action is removed. Therefore, my guess is that this is at root a specificity-evaluation issue, so I'm entering this under "compiles but misbehaves".

imported from: [Mantis 1802] Rule for printing a parser error does not acknowledge "while " as part of specificity when choosing best rule?
  • status: Reported
  • resolution: Open
  • resolved: 2022-04-07T05:00:50+10:00
  • imported: 2022/01/10
curiousdannii-testing commented 2 years ago

557058:4c095ffd-6d6f-47ce-9e73-77c613347b86:

Comment by zarf :
I see two separate issues in your example.

curiousdannii-testing commented 2 years ago

557058:4c095ffd-6d6f-47ce-9e73-77c613347b86:

Comment by zarf :
The code generated for the "while examining" rule is:


if (((((((action ==##Examine) && (actor==player) && (self=actor,true) && (((etype == I83_can_t_see_any_such_thing))))))))) { ! Runs only while condition holds

But at the time the parser-error rulebook runs, action is ##Waiting (the "null value" for action names). Only action_to_be has been set.

You can verify this:


Parser action-to-be is an action name that varies. The parser action-to-be variable translates into I6 as "action_to_be".

Parser action-global is an action name that varies. The parser action-global variable translates into I6 as "action".

Rule for printing a parser error when the latest parser error is the can't see any such thing error:
say "[parser action-to-be]> [current action]> [parser action-global]> The what now?"

curiousdannii-testing commented 2 years ago

557058:4c095ffd-6d6f-47ce-9e73-77c613347b86:

Comment by otistdog :
zarf,

Yes. The second issue is the item of greatest interest for the report, thus the title.

As for the first issue: By the point at which these would apply, the parsing should be done (having ended in an error), shouldn't it? The code generated for the "while examining" rule looks perfectly capable of being evaluated true – if given the chance. The value of action_to_be will be ##Examine and the value of actor will be the yourself object, and etype will be set for the "can't see any such thing error". The only remaining condition is "&& (self=actor, true)", which, if I'm reading it correctly, assigns the current value of actor to self and then invariably evaluates true.

curiousdannii-testing commented 2 years ago

557058:4c095ffd-6d6f-47ce-9e73-77c613347b86:

Comment by otistdog :
Oh, man. I looked at that a dozen times and didn't notice that the generated condition was testing action instead of action_to_be. How foolish, and thank you for the gentle correction.