scriptsharp icon indicating copy to clipboard operation
scriptsharp copied to clipboard

Declaring a field with the same name as a type

Open imnaseer opened this issue 10 years ago • 0 comments

The compiler generates a truncated file if the code does a type check on a type and there is a field with the same name as the type.

The following snippet will reproduce the internal crash:

public class Class1
{
    public BaseClass BaseClass = new BaseClass();

    public void Foo()
    {
        BaseClass obj = new BaseClass();
        bool isBaseClass;
        if (obj is BaseClass)
        {
            isBaseClass = true;
        }
       else
       {
           isBaseClass = false;
       }
    }
}

Changing the field named BaseClass to another name and/or removing the "is" type check will lead to correct js code.

imnaseer avatar Sep 15 '14 03:09 imnaseer