Beef icon indicating copy to clipboard operation
Beef copied to clipboard

[Bug] Type resolution error occurs when using a getter through a derived class pointer array element.

Open es-yuvanw opened this issue 2 years ago • 0 comments

Summary

A compilation error occurs when the following criteria is satisfied:

  • A pointer to a derived class instance is access through the array indexing operator.
  • That pointer is used to access a getter in the base class.

In this case, the return type of the getter is determined to be void.

Minimal repro case:

using System;

namespace HelloWorld
{
	struct Foo
	{
		public int bar;
	}

	struct Base
	{
		private Foo _foo;
		public Foo foo => _foo;
	}

	struct Derived : Base
	{
	}

	class Program
	{
	    static void Main()
	    {
	        Derived*[1] derived = ?;
	        Console.WriteLine("bar: {}", derived[0].foo.bar);
	    }
	}
}

Compilation error:

ERROR: Unable to find member 'bar' in 'void' at line 25:57 in /Project/src/Program.bf
            Console.WriteLine("bar: {}", derived[0].foo.bar);

Code

https://trybeef.netlify.app/#/JGCWIR

es-yuvanw avatar Mar 29 '23 01:03 es-yuvanw