Re: [Nemerle] Help - Solver.PushState() / Solver.PopState()

2 views
Skip to first unread message

Michal Moskal

unread,
Oct 1, 2008, 4:16:23 AM10/1/08
to VladD2, nemer...@googlegroups.com
There is the typer.TryTyping() method. You pass it a lambda expression
that you want to try (i.e. typer.TryTyping(fun() {
typer.TyperExpr(expr) })).

The method does something similar to what you do, but the catch is
that if it succeeds, you need to pop the state and run the typing
*again*. But if you use TryTyping() you should be safe.

Hope this helps!
Michał

On Tue, Sep 30, 2008 at 5:05 PM, VladD2 <v...@rsdn.ru> wrote:
> Hi,
>
> I try implement the linq-macro (LIQN for Nemerle) and I have a problem.
> I need type member call. But, typing can fail. If it fail I reject
> this method and use another one.
> In short - I need *TRY* tying.
> I try following approach:
> def isSupportExpressionTree(method : PExpr, resTy : PExpr) : bool
> {
> typer.Solver.PushState ();
> try {
> def expr = <[ $method(null :
> System.Linq.Expressions.Expression[System.Func[_, $resTy]]) ]>;
> def tExpr = typer.TypeExpr(expr);
> !(method.TypedObject is TExpr.Error)
> } finally { typer.Solver.PopState() }
> }
> But, it code (typer.Solver.PushState () / typer.Solver.PopState())
> case assertion (ICE) in:
> http://nemerle.org/svn/nemerle/trunk/ncc/typing/TyVar.n line 962 (in
> method WillRead ())
> if it run more then one time. :(
>
> I can't understand what I should do. :(
>
> Help, please!
>

Reply all
Reply to author
Forward
0 new messages