curiousdannii-testing / inform7-imported-bugs

0 stars 0 forks source link

[I7-1918] [Mantis 1954] Inconcise error message when checking for relations to non-existing nouns #166

Closed curiousdannii-testing closed 2 years ago

curiousdannii-testing commented 2 years ago

Reported by : FictitiousFrode

Description :

This is a tricky one; if you try to check for a relation on a noun in an action that doesn't have one, you get a message that's not very informative.
The fix is of course to check that the noun is a thing first. It can be argued whether the best approach here would be to let the if statement fail, but the error message could be more concise.

Steps to reproduce :

Library is a room.
Before doing something:
    If the noun is part of a thing (called N), say the printed name of N;

Additional information :

Result:
>z

[** Programming error: tried to find the "." of (something) **]
Time passes.

imported from: [Mantis 1954] Inconcise error message when checking for relations to non-existing nouns
  • status: Closed
  • resolution: Open
  • resolved: 2022-04-07T05:01:54+10:00
  • imported: 2022/01/10
curiousdannii-testing commented 2 years ago

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

Comment by zarf :
Confirmed.

The error message is coming from I6 veneer sanity-checking, and I'd say it's a mistake to let it ge that far. Note that if you instead wrote "If the noun is in a thing..." you'd get a veneer error message only when compiling in debug mode.

I7's type system is loose enough that any object variable (thing variable, person variable, etc) can contain "nothing" as a value. So I don't like that the compiler can generate "((noun.component_parent) ofclass K2_thing)" without any guard against "nothing".

The guard could either assume false or generate an explicit run-time error. I don't have a strong opinion about that.

curiousdannii-testing commented 2 years ago

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

Comment by FictitiousFrode :
I don't have a very strong opinion either, but then I did assume that it would return false.
(My original code had it in a nested else-if, making it slightly harder to spot)

curiousdannii-testing commented 2 years ago

61eedb62875fc10070240916:

Fixed via this commit: https://github.com/ganelson/inform/commit/420542d339abfcd9c8fb2f59354335fb64040ea2

Comment by Graham Nelson:
This really only applies to the incorporation relation, despite the name of the bug case. For consistency with the other spatial relations, the condition "N is part of X" should fail silently if N is nothing, or is an object which is not a thing (for example, a room), and that is now what happens. So the sample text produces no programming error and the rule works as intended.