slang icon indicating copy to clipboard operation
slang copied to clipboard

Properly handle the mismatching "mutating" signature for implementing interfaces

Open jkwak-work opened this issue 8 months ago • 1 comments

Problem description When the interface declares a function with [mutating], the implementation also has to have [mutating]. If the implementation didn't have the keyword, Slang crashes with an internal error.

Goal We should print a proper error for the mistake. Or it should work even when the implementation didn't have the matching [mutating] keyword.

Repro steps The following code can reproduce the issue.

//TEST:SIMPLE:
//TEST:SIMPLE:-DWITH_MUTATING
interface IHitInfo
{
};

interface IClosestHitQuery
{
    [mutating] void traceRay(out IHitInfo hit);
};

struct GeneratePathClosestHitQuery : IClosestHitQuery
{
#if defined(WITH_MUTATING)
    [mutating]
#endif
    void traceRay(out IHitInfo hit)
    {
        hit = {};
    }
};

Note that the modifier out is required to reproduce the issue.

jkwak-work avatar Jun 24 '24 17:06 jkwak-work