Type mismatches when using Interfaces with _NoncopyableType decoration #3898
Labels
goal:quality & productivity
Quality issues and issues that impact our productivity coding day to day inside slang
kind:enhancement
a desirable new feature, option, or behavior
Creating this as a child issue of #3671 where the problem was originally found while writing the following targeted test:
Test Case: ctor-retval-legal.slang.txt
The root-cause is that there is a mismatch between the call operands and the callee signature when invoking a constructor or a member function within a struct that is derived from an interface.
Something like this:
The function signature of the following
__init(float);
__init();
are represented as
Further digging down to the
kIROp_Call
where the crash happens, there is only one operand set askIROp_Func
with the assumption of ordinary struct type function signaturesbut for this case, it should be two:
that is why the assertion happens, when we do a
when
argCounter
is 1 to access theRef(%Impl)
, but the total args is 1.Some comments from Yong on this topic:
The problem is that in the generic function, T is assumed to be an ordinary type, so the call to ctor is in the ordinary form. When we substitute the callee with the actual ctor, that will cause a mismatch. In general, the function signature defined in the interface must be binary compatible with the function signature of the actual implementation. In the case of non copyablr type, this assumption is broken.
The right fix is for the type system to not think that a noncopyable type’s ctor can satisfy the ctor requirement defined in the interface. Or we need to make compiler understand what it means for an interface to be decorated noncopyable, and only allow a noncopyable type to implement a noncopyable interface.
The text was updated successfully, but these errors were encountered: