microsoft / hlsl-specs

HLSL Specifications
MIT License
124 stars 34 forks source link

Prefix and postfix increment and decrement operator overloading doesn't work #281

Open llvm-beanz opened 2 years ago

llvm-beanz commented 2 years ago

With -HV 2021, the code below produces the diagnostic error: scalar, vector, or matrix expected.

If increment and decrement operators are expected to work we should fix that, if not, we should provide a more useful diagnostic.

struct Foo {
  int x;
  void operator++(int){
    x += 1;
  }

  void operator++(){
    x += 1;
  }
};

[numthreads(1, 1, 1)]
void main(uint tidx : SV_DispatchThreadId) {
  Foo A = {11};
  A++;
  ++A;
}
llvm-beanz commented 2 years ago

We get the same bad errors for the unary operators ~ and !.

jaebaek commented 2 years ago

Oops. I will take a look

damyanp commented 3 months ago

We've removed support for the offending operators in HLSL 2021. We should view this as a feature request for HLSL 202x.