renode icon indicating copy to clipboard operation
renode copied to clipboard

C# compiler rejects some valid array initialization syntax

Open xobs opened this issue 3 years ago • 1 comments

The C# compiler sometimes rejects valid array initialization syntax, particularly when it comes to double arrays.

For example:

public class TestClass
{
    public byte[] Read(int count = 1)
    {
        return stubData[0];
    }
    private byte[][] stubData = new byte[][] {
            new byte[] {0, 1, 2},
            new byte[] {3, 4, 5},
            new byte[] {6, 7, 8},
        };
}

This is rejected by the Renode compiler:

(monitor) i @emulation/peripherals/example.cs
14:21:49.6714 [INFO] Including script: E:\Code\Xous\Core\emulation\peripherals\example.cs (6)
Errors during compilation or loading:
Could not compile assembly: E:\Code\Xous\Core\emulation\peripherals\example.cs(1,14):
(monitor)

A workaround is to leave the arrays uninitialized and initialize them at runtime.

xobs avatar Feb 26 '22 06:02 xobs

Hi @xobs

I can confirm the issue. Sadly, it's Windows-specific. On Linux this file loads just fine, and in various combinations. On Windows it always fails. What's more, the error message is empty, so I'd suspect a compiler crash. We'll try to investigate this further.

PiotrZierhoffer avatar Mar 02 '22 00:03 PiotrZierhoffer