diff --git a/docs/knowledge-module/2-nv.html b/docs/knowledge-module/2-nv.html index 8fa2211e16..b548033abc 100644 --- a/docs/knowledge-module/2-nv.html +++ b/docs/knowledge-module/2-nv.html @@ -172,8 +172,12 @@
§4.2. Four oddball cases have special behaviour: +
§4.2. This typically arises for timing reasons. At the time the variable has to be +created, and given a kind, the kind of the initial value has not been fully +determined. So K here will be something like phrase value -> value. If this +case arose often enough it might be worth refactoring everything, but it's +rarely occurring and has an easy workaround. So we will just give a fairly +helpful problem message: +
+ +Issue problem message for a phrase used before its kind is known4.2 = +
+ ++ LOG("W = %W, Domain = %u\n", W, K); + Problems::quote_wording(1, W); + StandardProblems::handmade_problem(Task::syntax_tree(), + _p_(PM_IndefiniteVariable2)); + Problems::issue_problem_segment( + "I am unable to create '%1', because the text was too vague about what " + "its kind should be - I can see it's a phrase, but not what kind of phrase. " + "(You may be able to fix this by declaring the kind directly first. For " + "example, rather than 'The magic word is initially my deluxe phrase.', " + "something like 'The magic word is a phrase nothing -> nothing variable. " + "The magic word is initially my deluxe phrase.')"); + Problems::issue_problem_end(); ++
§4.3. Four oddball cases have special behaviour:
nonlocal_variable *NonlocalVariables::nothing_pseudo_variable(void) { @@ -250,7 +280,7 @@-return temporary_global_VAR; }
§4.4. Notice a few special variables4.4 = +
§4.5. Notice a few special variables4.5 =
diff --git a/inform7/Figures/timings-diagnostics.txt b/inform7/Figures/timings-diagnostics.txt index 28b7278f9a..9dd7987118 100644 --- a/inform7/Figures/timings-diagnostics.txt +++ b/inform7/Figures/timings-diagnostics.txt @@ -1,10 +1,10 @@ 100.0% in inform7 run - 71.5% in compilation to Inter - 50.8% in //Sequence::undertake_queued_tasks// + 71.4% in compilation to Inter + 51.2% in //Sequence::undertake_queued_tasks// 4.6% in //MajorNodes::pre_pass// 3.4% in //MajorNodes::pass_1// - 2.0% in //RTPhrasebook::compile_entries// 1.8% in //ImperativeDefinitions::assess_all// + 1.8% in //RTPhrasebook::compile_entries// 1.4% in //RTKindConstructors::compile// 1.2% in //Sequence::lint_inter// 0.6% in //MajorNodes::pass_2// @@ -16,8 +16,8 @@ 0.2% in //InferenceSubjects::emit_all// 0.2% in //RTKindConstructors::compile_permissions// 0.2% in //Task::make_built_in_kind_constructors// - 2.6% not specifically accounted for - 25.8% in running Inter pipeline + 2.4% not specifically accounted for + 25.9% in running Inter pipeline 10.3% in step 14/15: generate inform6 -> auto.inf 5.6% in step 5/15: load-binary-kits 5.2% in step 6/15: make-synoptic-module @@ -27,6 +27,6 @@ 0.4% in step 7/15: shorten-wiring 0.4% in step 8/15: detect-indirect-calls 0.2% in step 11/15: eliminate-redundant-labels - 1.3% not specifically accounted for + 1.5% not specifically accounted for 2.2% in supervisor 0.5% not specifically accounted for diff --git a/inform7/Tests/Test Problems/PM_IndefiniteVariable2.txt b/inform7/Tests/Test Problems/PM_IndefiniteVariable2.txt new file mode 100644 index 0000000000..7e5870efca --- /dev/null +++ b/inform7/Tests/Test Problems/PM_IndefiniteVariable2.txt @@ -0,0 +1,5 @@ +Home is a room. + +To waste time (this is wasting time): do nothing. + +The phrase in question is always wasting time. diff --git a/inform7/Tests/Test Problems/_Results_Ideal/PM_IndefiniteVariable2.txt b/inform7/Tests/Test Problems/_Results_Ideal/PM_IndefiniteVariable2.txt new file mode 100644 index 0000000000..0efd87b39e --- /dev/null +++ b/inform7/Tests/Test Problems/_Results_Ideal/PM_IndefiniteVariable2.txt @@ -0,0 +1,13 @@ +Inform 7 v10.1.0 has started. +I've now read your source text, which is 21 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 32162 words long. +Problem__ PM_IndefiniteVariable2 + >--> I am unable to create 'phrase in question', because the text was too + vague about what its kind should be - I can see it's a phrase, but not what + kind of phrase. (You may be able to fix this by declaring the kind directly + first. For example, rather than 'The magic word is initially my deluxe + phrase.', something like 'The magic word is a phrase nothing -> nothing + variable. The magic word is initially my deluxe phrase.') +Inform 7 has finished. diff --git a/inform7/knowledge-module/Chapter 2/Nonlocal Variables.w b/inform7/knowledge-module/Chapter 2/Nonlocal Variables.w index e20cc06244..7c83b18538 100644 --- a/inform7/knowledge-module/Chapter 2/Nonlocal Variables.w +++ b/inform7/knowledge-module/Chapter 2/Nonlocal Variables.w @@ -101,8 +101,12 @@ nonlocal_variable *NonlocalVariables::get_latest(void) { nonlocal_variable *NonlocalVariables::new(wording W, kind *K, shared_variable *shv) { if (K == NULL) internal_error("created variable without kind"); - if (Kinds::Behaviour::definite(K) == FALSE) - @; + if (Kinds::Behaviour::definite(K) == FALSE) { + if (Kinds::get_construct(K) == CON_phrase) + @ + else + @ ; + } nonlocal_variable *nlv = CREATE(nonlocal_variable); latest_nonlocal_variable = nlv; @@ -138,6 +142,27 @@ nonlocal_variable *NonlocalVariables::new(wording W, kind *K, shared_variable *s "is a list of numbers that varies' would be better."); Problems::issue_problem_end(); +@ This typically arises for timing reasons. At the time the variable has to be +created, and given a kind, the kind of the initial value has not been fully +determined. So |K| here will be something like |phrase value -> value|. If this +case arose often enough it might be worth refactoring everything, but it's +rarely occurring and has an easy workaround. So we will just give a fairly +helpful problem message: + +@ = + LOG("W = %W, Domain = %u\n", W, K); + Problems::quote_wording(1, W); + StandardProblems::handmade_problem(Task::syntax_tree(), + _p_(PM_IndefiniteVariable2)); + Problems::issue_problem_segment( + "I am unable to create '%1', because the text was too vague about what " + "its kind should be - I can see it's a phrase, but not what kind of phrase. " + "(You may be able to fix this by declaring the kind directly first. For " + "example, rather than 'The magic word is initially my deluxe phrase.', " + "something like 'The magic word is a phrase nothing -> nothing variable. " + "The magic word is initially my deluxe phrase.')"); + Problems::issue_problem_end(); + @ Four oddball cases have special behaviour: (*) |Inter_nothing_VAR| is translated not to an Inter variable, but to the Inter constant |nothing|.