fusionlanguage / fut

Fusion programming language. Transpiling to C, C++, C#, D, Java, JavaScript, Python, Swift, TypeScript and OpenCL C.
https://fusion-lang.org
GNU General Public License v3.0
1.76k stars 55 forks source link

Reference example of Dictionary is not working #134

Closed serkonda7 closed 1 year ago

serkonda7 commented 1 year ago

I have this code in the playground. It's basically the hello world with a few lines from the reference pasted:

public class HelloFu
{
    public static string GetMessage()
    {
        Dictionary<string(), int> dict;
        dict["foo"] = 42;
        dict["foo"] = 1337;
        Console.WriteLine(dict["foo"]);
        return "Hello, world!";
    }
}

However these two lines fail with an error.

  dict["foo"] = 42;
  dict["foo"] = 1337;
cannot modify array trough read-only reference
pfusik commented 1 year ago

Thank you for reporting this! It should be:

Dictionary<string(), int>() dict;

I fixed it in the reference.