-
Notifications
You must be signed in to change notification settings - Fork 74
Switch statements with string keys #8
Comments
noticed that there is a problem with references, as project still uses a mix of scriptsharp mscorlib.dll and saltarelle dlls. please ignore this till i resolve issue myself. |
I do believe this is a real issue |
Turned out I was wrong. Switching on strings does work. |
Ok, now my project does build but case statements still don't work, so i had to comment them. You are right, switching on strings does work, but if strings are set of constants defined in another class, it doesn't. I have a class like this:
If i change case statement to use inline strings it works. I'm trying to convert a big ScriptSharp project (about 5 MB of *.cs files) to your compiler. Had some issues but i could manage it to build with several changes / search replaces mostly. I'll let you know about issues i encountered later, so maybe you can write them in your wiki, and it may help others. Anyway, your project looks promising. I'd like to contribute. |
Can't reproduce this.
generates
Perhaps you need to update-package to get the latest version. For some reason, NuGet seems to install an old version when installing the compiler as a dependency. |
And, contributions are of course welcome. Drop me an email and we can discuss it more. |
Cloned your git repository but still getting similar error in switch statements. Created an empty project for testing but this time got a Internal Compiler Error: Can you please confirm this works with yours? (If i decrease number of case statements i got no error)
In test project i got:
In my main project i still have:
|
The first internal compiler error is due to the work-around you are using to get Visual Studio IntelliSense working, it's an internal error in csc.exe, not in Saltarelle. Most likely due to a missing member in my runtime lib. |
I just managed to reproduce and resolve the issue. |
When i write some switch statement that operates on string like:
I get an error like below:
Error 24
System.Collections.Generic.Dictionary<string,int>.Dictionary(int)' is obsolete:
This is only for use by the c# compiler, and cannot be used for generating script.'A field or property
System.Collections.Generic.Dictionary<TKey,TValue>' cannot be initialized with a collection object initializer because type
System.Collections.Generic.Dictionary<string,int>' does not implement `System.Collections.IEnumerable' interfaceThe text was updated successfully, but these errors were encountered: