Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null checks are not working in arrays #110

Open
MishaTy opened this issue Jul 25, 2021 · 0 comments
Open

Null checks are not working in arrays #110

MishaTy opened this issue Jul 25, 2021 · 0 comments
Assignees

Comments

@MishaTy
Copy link
Contributor

MishaTy commented Jul 25, 2021

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;
    }
}
@quajak quajak self-assigned this Jul 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants