Skip to content

Null checks are not working in arrays #110

@MishaTy

Description

@MishaTy

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;
    }
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions