Change (e as T) to not propagate self constraints; introduce (e asalso {c})

Description

In 2.1.2, (x as T) has type T{self==x}. This causes problems, particularly in settings where T is expected and T{self=x} will not do. The user, unfortunately has no way of specifying an expression which has the same value as x and is of type T other than by using circumlocutions such as var y:T=x;, and then using y instead of x.

We should change the semantics of (e as T) so that it has type T.

We should introduce e asalso {c} expressions, where c is a constraint. Let the static type of e be T. c may have occurrences of self, the type of self will be the base type of T. The static type of e asalso {c} will be T{c}; code will be generated to check the expression c at run-time.

Environment

None

Status

Assignee

VijayV

Reporter

VijayV

Labels

None

Components

Fix versions

Affects versions

Priority

High
Configure