History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: RSRP-56993
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Eugene Pasynkov
Reporter: Ilya Ryzhenkov
Votes: 1
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
ReSharper

Invalid parse of lambda with operators

Created: 31 Jan 08 13:21   Updated: 09 Apr 08 17:42
Component/s: PSI - Parser
Fix Version/s: Aroha
Security Level: Everybody (All jira users)

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown


 Description  « Hide
class B
{
    public static bool operator >(Action<int> x, B y)
    {
        return true;
    }
    public static bool operator <(Action<int> x, B y)
    {
        return false;
    }
    
    public static void Main()
    {
        Foo(x => {} > new B());
    }

    static void Foo(bool x) { }
}

This code compiles.



 All   Comments   Work Log   Change History      Sort Order:
Vladimir Reshetnikov - 31 Jan 08 13:24
The compiler does not strictly comply with the standard here.

Vladimir Reshetnikov - 31 Jan 08 13:35
class B
{
    public static bool operator *(Action<int> x, B y)
    {
        return true;
    }

    public static void Main()
    {
        Foo(x => { } * new B());
    }

    static void Foo(bool x) { }
}

Eugene Pasynkov - 31 Jan 08 15:01
Though it isn't mentioned in standard, lambda with "{}" block seems to have primary expression priority

Vladimir Reshetnikov - 31 Jan 08 15:39
This is not true, when the lambda is an operand of a cast operator, or a right oeprand of a binary operator:
var x = (Action<int>) x => {}; // error CS1525: Invalid expression term '=>'

Eugene Pasynkov - 31 Jan 08 16:45
Pending issue till fixes either in C# specs either in c# compiler

Vladimir Reshetnikov - 19 Feb 08 11:03
It seems, that it is better to parse lambda with statement block as primary expression for now. Further validation can be done later, when the rules become apparent.