IL2CPU
IL2CPU copied to clipboard
Null checks are not working in arrays
The virtual machine shuts down when reading from a null item from an array. Example code:
using System;
using System.Collections.Generic;
using System.Text;
using Sys = Cosmos.System;
namespace CosmosWeirdError
{
public class Kernel : Sys.Kernel
{
MyClass[] SomeArray = new MyClass[2];
protected override void BeforeRun()
{
try
{
Console.WriteLine("Cosmos booted successfully. Type a line of text to get it echoed back.");
//This should cause a null refrence expection, but instead the VM shuts down or shows a random value
Console.WriteLine(SomeArray[1].SomeValue);
}
catch(Exception x)
{
Console.WriteLine(x.Message);
}
}
protected override void Run()
{
Console.Write("Input: ");
var input = Console.ReadLine();
Console.Write("Text typed: ");
Console.WriteLine(input);
}
}
public class MyClass
{
public byte SomeValue;
}
}