Note that there are some explanatory texts on larger screens.

plurals
  1. POExplanation of Oslo error "M0197: 'Text' cannot be used in a Type context"?
    text
    copied!<p>In Microsoft Oslo SDK CTP 2008 (using Intellipad) the following code compiles fine:</p> <pre><code>module M { type T { Text : Text; } } </code></pre> <p>while compiling the below code leads to the error "M0197: 'Text' cannot be used in a Type context"</p> <pre><code>module M { type T { Text : Text; Value : Text; // error } } </code></pre> <p>I do not see the difference between the examples, as in the first case Text is also used in a Type context.</p> <p>UPDATE:</p> <p>To add to the confusion, consider the following example, which also compiles fine:</p> <pre><code>module M { type X; type T { X : X; Y : X; } } </code></pre> <p>The M Language Specification states that:</p> <blockquote> <p>Field declarations override lexical scoping to prevent the type of a declaration binding to the declaration itself. The ascribed type of a field declaration must not be the declaration itself; however, the declaration may be used in a constraint. Consider the following example:</p> <p>type A; type B { A : A; }</p> <p>The lexically enclosing scope for the type ascription of the field declaration A is the entity declaration B. With no exception, the type ascription A would bind to the field declaration in a circular reference which is an error. The exception allows lexical lookup to skip the field declaration in this case. </p> </blockquote> <p>It seems that user defined types and built-in (intrinsic) types are not treated equal.</p> <p>UPDATE2:</p> <p>Note that <em>Value</em> in the above example is not a reserved keyword. The same error results if you rename <em>Value</em> to <em>Y</em>.</p> <p>Any ideas?</p> <p>Regards, tamberg</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload