diff options
| author | Yong He <yonghe@outlook.com> | 2024-03-19 18:01:42 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-19 18:01:42 -0700 |
| commit | 1ee1688a70f1c099b24b5d479b4f08e3cf3ae410 (patch) | |
| tree | 88f857aeb0a94c09a9351e39b0971329625fddc0 | |
| parent | 05f403be96f0d991a3ef949e5a6a6fb3b416e1ff (diff) | |
Fix type checking for constructors in generic interfaces. (#3799)
| -rw-r--r-- | source/slang/slang-ast-type.cpp | 2 | ||||
| -rw-r--r-- | tests/bugs/gh-3792.slang | 25 |
2 files changed, 26 insertions, 1 deletions
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<DirectDeclRef>(substDeclRef.declRefBase)) + if (as<DirectDeclRef>(substDeclRef.declRefBase) || as<MemberDeclRef>(substDeclRef.declRefBase)) { if (as<ThisTypeDecl>(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<X> { + __init(const X x); +} +extension float: From<float> { + __init(const float x) { this = x; } +} +T test<T : From<float>>(float v) +{ + T u; + u = T(5.0f); + return u; +} + +RWStructuredBuffer<float> outputBuffer; +[numthreads(1,1,1)] +void computeMain() +{ + float v = test<float>(5.0); + //BUF: 5.0 + outputBuffer[0] = v; +}
\ No newline at end of file |
