yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
b42b865ac
master
1// keyword-undeclared-identifier.slang 2 3//DIAGNOSTIC_TEST:SIMPLE: 4 5// Test that using a contextual keyword in 6// a context where it is an underfined 7// identifier produces a reasonable error 8// message instead of an internal compiler error 9// 10// Note that HLSL has keywords with very 11// common names like `triangle` and `sample`, 12// so it is easy for those to collide with 13// local variable names. 14// 15// Slang decides to make almost all keywords 16// contextual, so that they are looked up 17// in lexical scope and can be shadowed by 18// user-defined variables or functions. 19// 20// The problem in this case is that code 21// could easily be refactored so that it 22// uses one of the contextual keywrods in 23// a place where it is no longer shadowed, 24// but contextually needs to be treated 25// as an expression. 26 27int instanceTest() 28{ 29 return instance; 30} 31 32int triangleTest() 33{ 34 return triangle; 35}