Skip to content

Commit

Permalink
Fix for Mantis bug 2002
Browse files Browse the repository at this point in the history
  • Loading branch information
ganelson committed Apr 10, 2022
1 parent efe630b commit f9e4403
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
9 changes: 9 additions & 0 deletions inform7/Tests/Test Problems/PM_UseOptionAtLeastNegative.txt
@@ -0,0 +1,9 @@
Foo is a room.
Use blurble of at least 0 translates as (- Constant BLURBLE = {N}; -).
Use blah of at least -10 translates as (- Constant BLAH = {N}; -).
Include (-
[ foo2 x; x = BLURBLE; ];
-).
Include (-
[ foo x; x = BLAH; ];
-).
@@ -0,0 +1,11 @@
Inform 7 v10.1.0 has started.
I've now read your source text, which is 30 words long.
I've also read Basic Inform by Graham Nelson, which is 7691 words long.
I've also read English Language by Graham Nelson, which is 2328 words long.
I've also read Standard Rules by Graham Nelson, which is 32092 words long.
Problem__ PM_UseOptionAtLeastNegative
>--> You wrote 'Use blah of at least -10 translates as (- Constant BLAH =
{N}; -)' (source text, line 3): but the minimum possible value is not
allowed to be negative, since it describes a quantity which must be 0 or
more
Inform 7 has finished.
Expand Up @@ -85,7 +85,7 @@ typedef struct use_option {
uo->name = GET_RW(<use-setting>, 1);
uo->expansion = OP;
uo->option_used = FALSE;
uo->minimum_setting_value = (N > 0) ? N : -1;
uo->minimum_setting_value = (N >= 0) ? N : -1;
uo->source_file_scoped = FALSE;
uo->notable_option_code = -1;
if (<notable-use-option-name>(uo->name)) uo->notable_option_code = <<r>>;
Expand Down
12 changes: 10 additions & 2 deletions inform7/assertions-module/Chapter 3/Use Option Requests.w
Expand Up @@ -51,13 +51,21 @@ option name is taken from the |...| or |###| as appropriate:
... language index ==> { TRUE, - }

<use-memory-setting> ::=
### of <cardinal-number-unlimited> ==> { R[1], - }
### of <cardinal-number-unlimited> ==> @<Validate the at-least setting@>

<use-setting> ::=
... of at least <cardinal-number-unlimited> | ==> { R[1], - }
... of at least <cardinal-number-unlimited> | ==> @<Validate the at-least setting@>
<definite-article> ... | ==> { -1, - }
... ==> { -1, - }

@<Validate the at-least setting@> =
if (R[1] < 0)
StandardProblems::sentence_problem(Task::syntax_tree(),
_p_(PM_UseOptionAtLeastNegative),
"the minimum possible value is not allowed to be negative",
"since it describes a quantity which must be 0 or more");
==> { R[1], - }

@<Set a single use option@> =
wording S = Node::get_text(p);
if (<use-inter-pipeline>(S))
Expand Down

0 comments on commit f9e4403

Please sign in to comment.