Explanation of Oslo error “M0197: ‘Text’ cannot be used in a Type context”?

Locked Explanation of Oslo error “M0197: ‘Text’ cannot be used in a Type context”?

All Replies

  • Friday, October 31, 2008 6:45 PM
     
     
    In the M language values can be used as types, so when you write:

        type T {
            Text : Text;
            Other : Text;
        }

    The binding of Other's type is to its sibling property named "Text". As you've noticed, in this case it is more a hinderance than a help. You can workaround this by using the fully qualified name for the text type of "Language.Text".

    -josh


  • Friday, October 31, 2008 9:03 PM
     
     
    Hi Josh,

    why is the same not holding in the case of user-defined types?

    e.g.
    module M {
        type X;
        type T {
          X : X;
          Y : X;
        }
    }

    Regards,
    tamberg


  • Friday, October 31, 2008 9:49 PM
     
     Answered

    The M compiler is reasonably relaxed about allow you to define empty types and not erroring until they become a problem.

    If you give the type X a meaningful type you will see an error.

        type X : Integer32;
        type T {
            X : X;
            Y : X;
        }

    This causes an error.

    If however the type of the field X is a collection then it would be valid, if a bit wierd...

     

    • Marked As Answer by edhickeyOwner Tuesday, November 04, 2008 7:19 PM
    •  
  • Sunday, November 02, 2008 4:34 PM
     
     
    Thanks