oslom

Explanation of Oslo error "M0197: 'Text' cannot be used in a Type context"?


In Microsoft Oslo SDK CTP 2008 (using Intellipad) the following code compiles fine:

module M {
    type T {
        Text : Text;
    }
}

while compiling the below code leads to the error "M0197: 'Text' cannot be used in a Type context"

module M {
    type T {
        Text : Text;
        Value : Text; // error
    } 
}

I do not see the difference between the examples, as in the first case Text is also used in a Type context.

UPDATE:

To add to the confusion, consider the following example, which also compiles fine:

module M {
    type X;
    type T {
      X : X;
      Y : X;
    } 
}

The M Language Specification states that:

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:

type A; type B { A : A; }

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.

It seems that user defined types and built-in (intrinsic) types are not treated equal.

UPDATE2:

Note that Value in the above example is not a reserved keyword. The same error results if you rename Value to Y.

Any ideas?

Regards, tamberg


Solution

  • http://social.msdn.microsoft.com/Forums/en-US/oslo/thread/fcaf10a1-52f9-4ab7-bef5-1ad9f9112948