From f9e44035e88f8f6ae05062e995f31a4d4e22915b Mon Sep 17 00:00:00 2001 From: Graham Nelson Date: Sun, 10 Apr 2022 09:37:34 +0100 Subject: [PATCH] Fix for Mantis bug 2002 --- .../Test Problems/PM_UseOptionAtLeastNegative.txt | 9 +++++++++ .../_Results_Ideal/PM_UseOptionAtLeastNegative.txt | 11 +++++++++++ .../Chapter 3/New Use Option Requests.w | 2 +- .../Chapter 3/Use Option Requests.w | 12 ++++++++++-- 4 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 inform7/Tests/Test Problems/PM_UseOptionAtLeastNegative.txt create mode 100644 inform7/Tests/Test Problems/_Results_Ideal/PM_UseOptionAtLeastNegative.txt diff --git a/inform7/Tests/Test Problems/PM_UseOptionAtLeastNegative.txt b/inform7/Tests/Test Problems/PM_UseOptionAtLeastNegative.txt new file mode 100644 index 0000000000..1ee8a4b328 --- /dev/null +++ b/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; ]; +-). diff --git a/inform7/Tests/Test Problems/_Results_Ideal/PM_UseOptionAtLeastNegative.txt b/inform7/Tests/Test Problems/_Results_Ideal/PM_UseOptionAtLeastNegative.txt new file mode 100644 index 0000000000..f6cbd31609 --- /dev/null +++ b/inform7/Tests/Test Problems/_Results_Ideal/PM_UseOptionAtLeastNegative.txt @@ -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. diff --git a/inform7/assertions-module/Chapter 3/New Use Option Requests.w b/inform7/assertions-module/Chapter 3/New Use Option Requests.w index 1e49b10857..bbbafafadb 100644 --- a/inform7/assertions-module/Chapter 3/New Use Option Requests.w +++ b/inform7/assertions-module/Chapter 3/New Use Option Requests.w @@ -85,7 +85,7 @@ typedef struct use_option { uo->name = GET_RW(, 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 ((uo->name)) uo->notable_option_code = <>; diff --git a/inform7/assertions-module/Chapter 3/Use Option Requests.w b/inform7/assertions-module/Chapter 3/Use Option Requests.w index 2b9ca0ba8c..9b6ad5e04d 100644 --- a/inform7/assertions-module/Chapter 3/Use Option Requests.w +++ b/inform7/assertions-module/Chapter 3/Use Option Requests.w @@ -51,13 +51,21 @@ option name is taken from the |...| or |###| as appropriate: ... language index ==> { TRUE, - } ::= - ### of ==> { R[1], - } + ### of ==> @ ::= - ... of at least | ==> { R[1], - } + ... of at least | ==> @ ... | ==> { -1, - } ... ==> { -1, - } +@ = + 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], - } + @ = wording S = Node::get_text(p); if ((S))