yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
b7d318f48
master
1// param-mutation.slang 2 3// When a parameter is passed to `in`, it is mutable but generates a warning as it probably (?) 4// isn't what the programmer intended. 5 6//DIAGNOSTIC_TEST:SIMPLE: 7 8struct MutatingStruct 9{ 10 [mutating] void setValue(int value) { m_value = value; } 11 int m_value; 12}; 13 14int doThing(MutatingStruct s, int v) 15{ 16 // Should generate a warning. 17 s.setValue(v + 1); 18 return s.m_value; 19} 20 21// For non-copyable types (such as HitObject or NonCopyableStruct declared below), if passed as as `in` 22// should produce an error. 23 24[__NonCopyableType] 25struct NonCopyableStruct 26{ 27 [mutating] void setValue(int value) { m_value = value; } 28 int m_value; 29}; 30 31int doThing2(NonCopyableStruct s, int v) 32{ 33 s.setValue(v + 1); 34 return s.m_value; 35} 36