Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No conversion to Linq Expression with MethodRef or StaticRef #407

Open
NN--- opened this issue Sep 3, 2012 · 0 comments
Open

No conversion to Linq Expression with MethodRef or StaticRef #407

NN--- opened this issue Sep 3, 2012 · 0 comments
Labels

Comments

@NN---
Copy link
Member

NN--- commented Sep 3, 2012

This code leads to problem:

using System;
using System.Linq.Expressions;

class Program
{
  public static F(_ : Expression[Func[int, void -> string]]) : void
  {
  }

  static X() : string { "" }
  Y() : string { "" }

  static Main() : void
  {
    F(a => X);
    F(a => Program().Y);
  }
}
---------------------------
Assertion Failed: Abort=Quit, Retry=Debug, Ignore=Continue
---------------------------
fail convertion to 'expression tree'



   at Nemerle.Linq.Converter.ToExpr(Map`2 lparms, TExpr texpr)

   at Nemerle.Linq.Converter.TryAddConvertion(Map`2 lparms, TypeVar requiredType, TExpr nestedExpr)

   at Nemerle.Linq.Converter.ToExpr(Map`2 lparms, TExpr texpr)

   at Nemerle.Linq.Converter.ConvertLambdaExpression(Map`2 lparms, TFunHeader header)

   at Nemerle.Linq.Converter.ToExpr(Map`2 lparms, TExpr texpr)

   at Nemerle.Linq.Converter..ctor(Typer typer, TExpr tExpr)

   at Nemerle.Linq.LinqExprConvertion._N__N_lambda__14481__14566.apply(PExpr pExpr, TExpr tExpr)

   at Nemerle.Compiler.Typer.TransformWhenAllTypesWouldBeInfered(Function`3 transform, TExpr tExpr, PExpr expr)

   at Nemerle.Linq.LinqExprConvertion.ToExpressionImpl(Typer typer, PExpr expr)

   at Nemerle.Linq.ToExpressionMacro.Run(Typer _N__1, list`1 parms)

   at Nemerle.Compiler.MacroRegistry.expand_one_macro(Typer ctx, PExpr expr)

   at Nemerle.Compiler.Typer.TypeExpr(PExpr expr, TypeVar expected, Boolean is_toplevel_in_seq)

   ......

<truncated>
---------------------------
Abort   Retry   Ignore   
---------------------------

While the same code compiles in C#

using System;
using System.Linq.Expressions;

class Program
{
  public static void F(Expression<Func<int, Func<string>>> x)
  {
  }

  static string X() { return ""; }
  string Y() { return ""; }

  static void Main()
  {
    F(a => X);
    F(a => Program().Y);
  }
}

Changing void -> string to Func[string] doesn't help:

  public static F(_ : Expression[Func[int, Func[string]]]) : void
  {
  }
error : in argument #1 (_N_wildcard_3658), needed a System.Linq.Expressions.Expression[System.Func[int, System.Func[string]]], got ? -> void -> string-: ? -> void -> string- is not a subtype of System.Linq.Expressions.Expression[System.Func[int, System.Func[string]]] [simple require]
error : in argument #1 (_N_wildcard_3658), needed a System.Linq.Expressions.Expression[System.Func[int, System.Func[string]]], got ? -> void -> string-: ? -> void -> string- is not a subtype of System.Linq.Expressions.Expression[System.Func[int, System.Func[string]]] [simple require]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant