From 1ee1688a70f1c099b24b5d479b4f08e3cf3ae410 Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 19 Mar 2024 18:01:42 -0700 Subject: Fix type checking for constructors in generic interfaces. (#3799) --- source/slang/slang-ast-type.cpp | 2 +- tests/bugs/gh-3792.slang | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 tests/bugs/gh-3792.slang diff --git a/source/slang/slang-ast-type.cpp b/source/slang/slang-ast-type.cpp index e8d702062..a398e2690 100644 --- a/source/slang/slang-ast-type.cpp +++ b/source/slang/slang-ast-type.cpp @@ -108,7 +108,7 @@ Val* DeclRefType::_substituteImplOverride(ASTBuilder* astBuilder, SubstitutionSe // If this declref type is a direct reference to ThisType or a Generic parameter, // and `subst` provides an argument for it, then we should just return that argument. // - if (as(substDeclRef.declRefBase)) + if (as(substDeclRef.declRefBase) || as(substDeclRef.declRefBase)) { if (as(substDeclRef.getDecl())) { diff --git a/tests/bugs/gh-3792.slang b/tests/bugs/gh-3792.slang new file mode 100644 index 000000000..6b6a7451c --- /dev/null +++ b/tests/bugs/gh-3792.slang @@ -0,0 +1,25 @@ +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUF): -shaderobj -output-using-type + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer + +interface From { + __init(const X x); +} +extension float: From { + __init(const float x) { this = x; } +} +T test>(float v) +{ + T u; + u = T(5.0f); + return u; +} + +RWStructuredBuffer outputBuffer; +[numthreads(1,1,1)] +void computeMain() +{ + float v = test(5.0); + //BUF: 5.0 + outputBuffer[0] = v; +} \ No newline at end of file -- cgit v1.2.3