Beef icon indicating copy to clipboard operation
Beef copied to clipboard

[BUG] Class with generic argument is ignoring base class constructor

Open M0n7y5 opened this issue 4 years ago • 1 comments

Below code cant be compiled without calling base class constructor. But if we uncomment that generic argument of TestMePls class, compilation will be executed without any errors which is wrong.

using System;
namespace BeefTest
{

	public abstract class Singleton
	{
	    public static Object test;

	    public this(Object x)
	    {
	        test = x;
	    }
	}

	class TestMePls/*<T>*/ : Singleton
	{
		[Test]
		public static void Tesst()
		{
			Test.Assert(true);
		}
	}
}

M0n7y5 avatar Jul 27 '21 15:07 M0n7y5

On latest nightly (https://github.com/beefytech/Beef/commit/b4cfc119a7ee6d108045f77d0f63776fb2a539cf) this is no longer an issue. Provided code will not compile because of the error, with or without generic argument.

With generic argument:

ERROR: No parameterless constructor is available for base class.
Consider calling base constructor 'bug1120.Singleton.this(System.Object x)'.
  while specializing type 'bug1120.TestMePls<float>' at line 29:7 in r:\bug.1120\src\Program.bf
class TestMePls<T> : Singleton
      ^^^^^^^^^
  > See method declaration at line 23:12 in r:\bug.1120\src\Program.bf
     public this(Object x)
            ^^^^

Without generic argument:

ERROR: No parameterless constructor is available for base class.
Consider calling base constructor 'bug1120.Singleton.this(System.Object x)'. Line 29:7 in r:\bug.1120\src\Program.bf
class TestMePls : Singleton
      ^^^^^^^^^
  > See method declaration at line 23:12 in r:\bug.1120\src\Program.bf
     public this(Object x)
            ^^^^

However, with generic argument, error-squiggles are not rendered, but error appears in 'Errors' tab. There is an issue about error-squiggles not showing in some cases, I'll add it there, once I get there.

kallisto56 avatar Jan 22 '25 19:01 kallisto56