Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions source/slang/slang-diagnostics.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4474,6 +4474,13 @@ err(
span { loc = "location", message = "arg ~argIndex:Int in '~funcName:IRInst' is not a compile-time constant" }
)

err(
"unsupported-assignment-target",
40017,
"assignment target is not supported",
span { loc = "location", message = "this form of assignment is not currently supported; consider assigning to the whole value instead of an individual element" }
Comment thread
expipiplus1 marked this conversation as resolved.
)

err(
"cannot-unroll-loop",
40020,
Expand Down
16 changes: 15 additions & 1 deletion source/slang/slang-lower-to-ir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10081,7 +10081,21 @@ void assign(IRGenContext* context, LoweredValInfo const& inLeft, LoweredValInfo
break;

default:
Comment thread
expipiplus1 marked this conversation as resolved.
SLANG_UNIMPLEMENTED_X("assignment");
{
SourceLoc loc;
for (auto locInfo = context->irBuilder->getSourceLocInfo(); locInfo;
locInfo = locInfo->next)
{
if (locInfo->sourceLoc.getRaw() != 0)
{
loc = locInfo->sourceLoc;
break;
}
}
Comment thread
expipiplus1 marked this conversation as resolved.
context->getSink()->diagnose(Diagnostics::UnsupportedAssignmentTarget{
Comment thread
expipiplus1 marked this conversation as resolved.
.location = loc,
});
Comment thread
expipiplus1 marked this conversation as resolved.
}
Comment thread
expipiplus1 marked this conversation as resolved.
break;
}
}
Expand Down
34 changes: 34 additions & 0 deletions tests/diagnostics/indexed-property-assign.slang
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//DIAGNOSTIC_TEST:SIMPLE(diag=CHECK): -target spirv -entry computeMain
Comment thread
expipiplus1 marked this conversation as resolved.

// Regression test for https://github.com/shader-slang/slang/issues/7160
// Assigning to an indexed element of an array-returning property should
// produce a diagnostic instead of crashing with an internal error.

struct Foo
{
float a;
float _b[2];

property float b[2]
{
get { return _b; }
set
{
_b[0] = newValue[0];
_b[1] = newValue[1];
}
}
}
Comment thread
expipiplus1 marked this conversation as resolved.

RWStructuredBuffer<float> output;

[shader("compute")]
[numthreads(1, 1, 1)]
void computeMain()
{
Foo c;
c.b[0] = 1.0;
Comment thread
expipiplus1 marked this conversation as resolved.
//CHECK: ^ assignment target is not supported
Comment thread
expipiplus1 marked this conversation as resolved.
Comment thread
expipiplus1 marked this conversation as resolved.
//CHECK: ^ this form of assignment is not currently supported; consider assigning to the whole value instead of an individual element
Comment thread
expipiplus1 marked this conversation as resolved.
Comment thread
expipiplus1 marked this conversation as resolved.
Comment thread
expipiplus1 marked this conversation as resolved.
Comment thread
expipiplus1 marked this conversation as resolved.
output[0] = c.b[0];
}
Loading