diff options
| author | Copilot <198982749+Copilot@users.noreply.github.com> | 2025-07-02 21:50:55 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-02 21:50:55 +0000 |
| commit | 05ff8850c8c3d3049c1f429672750f8904d4b808 (patch) | |
| tree | 63944460cf0a7b7bf312231799892a95c9c6fecd /source | |
| parent | 3e1dd65adff0873e0385040c5c0a003eda83de3b (diff) | |
Fix crash when using wrong type for inout parameter with WGSL target (#7588)
* Initial plan
* Fix crash in WGSL L-value cast lowering with type mismatches
Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
* Apply formatting to fix
Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
* Update test to verify successful compilation instead of error checking
Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: csyonghe <2652293+csyonghe@users.noreply.github.com>
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/slang-ir-lower-l-value-cast.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/source/slang/slang-ir-lower-l-value-cast.cpp b/source/slang/slang-ir-lower-l-value-cast.cpp index 3d3c15132..058589862 100644 --- a/source/slang/slang-ir-lower-l-value-cast.cpp +++ b/source/slang/slang-ir-lower-l-value-cast.cpp @@ -175,8 +175,17 @@ struct LValueCastLoweringContext IRBuilder builder(m_module); - IRType* toValueType = as<IRPtrType>(toType)->getValueType(); - IRType* fromValueType = as<IRPtrType>(fromType)->getValueType(); + auto toPtrType = as<IRPtrTypeBase>(toType); + auto fromPtrType = as<IRPtrTypeBase>(fromType); + + if (!toPtrType || !fromPtrType) + { + // If either type is not a pointer type, we cannot process this L-value cast + return; + } + + IRType* toValueType = toPtrType->getValueType(); + IRType* fromValueType = fromPtrType->getValueType(); for (auto useSite : useSites) { |
