[nem-en] RFC: matching variant options against non-variant values
Michal Moskal
michal.moskal at gmail.com
Tue May 1 00:13:09 CEST 2007
On 4/30/07, vc <vc at rsdn.ru> wrote:
> > I've just commited a change on trunk to disallow the following code:
> >
> > foo (o : object) : void
> > {
> > match (o) {
> > | [ x, y ] => ... x + y ...
> > | _ => ...
> > }
> > }
> > ...
>
> Michał, after this commit in Integration project appears many error
> messages.
>
> We use object fields for keep data of different types (for examle, TExpr and
> Parsetree.Fun_parm):
>
> _pexprObject = match (_pexprObject :> PExpr)
> {
> | PExpr.As (_, Splicable.Name as name) when IsIn(name.Location)
> | PExpr.Member(_, Splicable.Name as name) when IsIn(name.Location) => ...
> | parm is P.Fun_parm when IsIn(parm.name.Location) => setobj(parm.name);
> | o => o;
> }
>
> This change duress we make many changes :(.
I don't have SVN access right now to revert it. I'll do that tomorrow.
You can comment out the check in Typer-PatternTyper.n:
+ def parent = ti.SuperClass ().Value.GetFreshType ();
+ when (! matched_value_type.Require (parent))
+ ReportError (messenger,
+ $ "the matched value type "
+ "$matched_value_type was expected "
+ "to be subtype of $parent");
(It's important to comment out the Require() call too).
--
Michał
More information about the devel-en
mailing list