Skip to content

Commit

Permalink
Fixed Jira bug I7-2278
Browse files Browse the repository at this point in the history
  • Loading branch information
ganelson committed Nov 17, 2024
1 parent d6cc842 commit aaf0aa9
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 11 deletions.
17 changes: 15 additions & 2 deletions docs/assertions-module/4-npa.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,27 @@ <h1><a href="../index.html">
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="function-syntax">&lt;k-kind&gt;</span><span class="plain-syntax">(</span><span class="identifier-syntax">Node::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">p</span><span class="plain-syntax">))) &amp;&amp;</span>
<span class="plain-syntax"> ((</span><span class="function-syntax">&lt;&lt;rp&gt;&gt;</span><span class="plain-syntax"> == </span><span class="identifier-syntax">K_number</span><span class="plain-syntax">) || (</span><span class="function-syntax">&lt;&lt;rp&gt;&gt;</span><span class="plain-syntax"> == </span><span class="identifier-syntax">K_text</span><span class="plain-syntax">))) {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">PK</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">; </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="function-syntax">&lt;k-kind&gt;</span><span class="plain-syntax">(</span><span class="identifier-syntax">Node::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">p</span><span class="plain-syntax">))) </span><span class="identifier-syntax">PK</span><span class="plain-syntax"> = </span><span class="function-syntax">&lt;&lt;rp&gt;&gt;</span><span class="plain-syntax">;</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">PK</span><span class="plain-syntax"> == </span><span class="identifier-syntax">K_number</span><span class="plain-syntax">) || (</span><span class="identifier-syntax">PK</span><span class="plain-syntax"> == </span><span class="identifier-syntax">K_text</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">UsingProblems::assertion_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(), </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_BareProperty</span><span class="plain-syntax">),</span>
<span class="plain-syntax"> </span><span class="string-syntax">"this would create a property called 'number' or 'text'"</span><span class="plain-syntax">,</span>
<span class="plain-syntax"> </span><span class="string-syntax">"and although bare names of kinds are usually allowed as properties, "</span>
<span class="plain-syntax"> </span><span class="string-syntax">"these aren't. Instead, try '... has a number called position.' or "</span>
<span class="plain-syntax"> </span><span class="string-syntax">"something like that, to give the property a name."</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Kinds::Behaviour::is_object</span><span class="plain-syntax">(</span><span class="identifier-syntax">PK</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">UsingProblems::assertion_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(), </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_BareObjectProperty</span><span class="plain-syntax">),</span>
<span class="plain-syntax"> </span><span class="string-syntax">"this would create a property whose name is also the name of a kind of object"</span><span class="plain-syntax">,</span>
<span class="plain-syntax"> </span><span class="string-syntax">"and although bare names of kinds are usually allowed as properties, those "</span>
<span class="plain-syntax"> </span><span class="string-syntax">"can't be names of kinds of object - that becomes too confusing when sentences "</span>
<span class="plain-syntax"> </span><span class="string-syntax">"involving 'to have' come up. (Suppose we allowed 'A person has a thing.' "</span>
<span class="plain-syntax"> </span><span class="string-syntax">"to create a new property, with no name, identified only by being a thing. "</span>
<span class="plain-syntax"> </span><span class="string-syntax">"What would a sentence like 'Dr Jones has a ray gun.' mean, then? Would it "</span>
<span class="plain-syntax"> </span><span class="string-syntax">"mean Jones has an actual ray gun, or only that his 'thing' property has "</span>
<span class="plain-syntax"> </span><span class="string-syntax">"the value 'ray gun'? That's too ambiguous. Instead 'A person has a thing "</span>
<span class="plain-syntax"> </span><span class="string-syntax">"called talisman. Professor Smith has the ray gun. The talisman of Dr Jones "</span>
<span class="plain-syntax"> </span><span class="string-syntax">"is the ray gun.' is much clearer.)"</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> }</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">inference_subject</span><span class="plain-syntax"> *</span><span class="identifier-syntax">owner_infs</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Node::get_subject</span><span class="plain-syntax">(</span><span class="identifier-syntax">owner_ref</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">K</span><span class="plain-syntax"> = </span><span class="identifier-syntax">KindSubjects::to_kind</span><span class="plain-syntax">(</span><span class="identifier-syntax">owner_infs</span><span class="plain-syntax">);</span>
<span class="plain-syntax"> </span><span class="identifier-syntax">Kinds::Behaviour::convert_to_enumeration</span><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">);</span>
Expand Down
14 changes: 7 additions & 7 deletions inform7/Figures/timings-diagnostics.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
100.0% in inform7 run
65.7% in compilation to Inter
43.3% in //Sequence::undertake_queued_tasks//
66.4% in compilation to Inter
43.7% in //Sequence::undertake_queued_tasks//
4.4% in //MajorNodes::pre_pass//
3.3% in //MajorNodes::pass_1//
3.7% in //MajorNodes::pass_1//
2.0% in //RTKindConstructors::compile//
1.6% in //ImperativeDefinitions::assess_all//
1.3% in //RTPhrasebook::compile_entries//
Expand All @@ -15,17 +15,17 @@
0.3% in //Sequence::undertake_queued_tasks//
0.3% in //Sequence::undertake_queued_tasks//
0.3% in //Task::make_built_in_kind_constructors//
4.7% not specifically accounted for
27.1% in running Inter pipeline
4.8% not specifically accounted for
26.4% in running Inter pipeline
8.8% in step 14/15: generate inform6 -> auto.inf
6.7% in step 5/15: load-binary-kits
5.7% in step 6/15: make-synoptic-module
5.4% in step 6/15: make-synoptic-module
2.0% in step 9/15: make-identifiers-unique
0.3% in step 11/15: eliminate-redundant-labels
0.3% in step 12/15: eliminate-redundant-operations
0.3% in step 4/15: compile-splats
0.3% in step 7/15: shorten-wiring
0.3% in step 8/15: detect-indirect-calls
2.1% not specifically accounted for
1.7% not specifically accounted for
6.4% in supervisor
0.7% not specifically accounted for
21 changes: 21 additions & 0 deletions inform7/Tests/Test Problems/PM_BareObjectProperty--I.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Inform 7 v10.2.0 has started.
I've now read your source text, which is 32 words long.
I've also read version 10.2.0 of Basic Inform by Graham Nelson, which is 10687 words long.
I've also read version 10.2.0 of English Language by Graham Nelson, which is 2330 words long.
I've also read version 10.2.0 of Standard Rules by Graham Nelson, which is 35526 words long.
Problem__ PM_BareObjectProperty
>--> You wrote 'The rock has an object' (source text, line 5): but this would
create a property whose name is also the name of a kind of object, and
although bare names of kinds are usually allowed as properties, those can't
be names of kinds of object - that becomes too confusing when sentences
involving 'to have' come up. (Suppose we allowed 'A person has a thing.' to
create a new property, with no name, identified only by being a thing. What
would a sentence like 'Dr Jones has a ray gun.' mean, then? Would it mean
Jones has an actual ray gun, or only that his 'thing' property has the
value 'ray gun'? That's too ambiguous. Instead 'A person has a thing called
talisman. Professor Smith has the ray gun. The talisman of Dr Jones is the
ray gun.' is much clearer.)
Problem__ PM_BareObjectProperty
>--> You wrote 'The rock has a thing' (source text, line 6): again, this
would create a property whose name is also the name of a kind of object.
Inform 7 has finished.
8 changes: 8 additions & 0 deletions inform7/Tests/Test Problems/PM_BareObjectProperty.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Problem: PM_BareObjectProperty

The rock is a thing.

A color is a kind of value. Red, green, blue are colors.
The rock has a color.
The rock has an object.
The rock has a thing.
17 changes: 15 additions & 2 deletions inform7/assertions-module/Chapter 4/New Property Assertions.w
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,27 @@ property *NewPropertyAssertions::recursively_declare(parse_node *owner_ref,
automatically creates it.

@<This is a leaf containing just a property name@> =
if ((<k-kind>(Node::get_text(p))) &&
((<<rp>> == K_number) || (<<rp>> == K_text))) {
kind *PK = NULL; if (<k-kind>(Node::get_text(p))) PK = <<rp>>;
if ((PK == K_number) || (PK == K_text)) {
UsingProblems::assertion_problem(Task::syntax_tree(), _p_(PM_BareProperty),
"this would create a property called 'number' or 'text'",
"and although bare names of kinds are usually allowed as properties, "
"these aren't. Instead, try '... has a number called position.' or "
"something like that, to give the property a name.");
}
if (Kinds::Behaviour::is_object(PK)) {
UsingProblems::assertion_problem(Task::syntax_tree(), _p_(PM_BareObjectProperty),
"this would create a property whose name is also the name of a kind of object",
"and although bare names of kinds are usually allowed as properties, those "
"can't be names of kinds of object - that becomes too confusing when sentences "
"involving 'to have' come up. (Suppose we allowed 'A person has a thing.' "
"to create a new property, with no name, identified only by being a thing. "
"What would a sentence like 'Dr Jones has a ray gun.' mean, then? Would it "
"mean Jones has an actual ray gun, or only that his 'thing' property has "
"the value 'ray gun'? That's too ambiguous. Instead 'A person has a thing "
"called talisman. Professor Smith has the ray gun. The talisman of Dr Jones "
"is the ray gun.' is much clearer.)");
}
inference_subject *owner_infs = Node::get_subject(owner_ref);
kind *K = KindSubjects::to_kind(owner_infs);
Kinds::Behaviour::convert_to_enumeration(K);
Expand Down

0 comments on commit aaf0aa9

Please sign in to comment.