nikhilk / scriptsharp

Script# Project - a C# to JavaScript compiler, to power your HTML5 and Node.js web development.
http://scriptsharp.com
Other
659 stars 183 forks source link

Declaring a field with the same name as a type #428

Open imnaseer opened 10 years ago

imnaseer commented 10 years ago

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.