https://github.com/shader-slang/slang
Raw File
Tip revision: e9bf8de3123563df6f2ca4d3b99291c6a8c99d5d authored by Tim Foley on 27 August 2020, 20:49:00 UTC
Enable simple extensions of interface types (#1521)
Tip revision: e9bf8de
variable-redeclaration.slang
// variable-redeclaration.slang

//DIAGNOSTIC_TEST:SIMPLE:


// This test confirms that the compiler produces
// suitable diagnostics when variables are redeclared
// in a given scope.

// Global variables, including shader parameters

static int gA;

static Texture2D gA;

// Local variables

int testLocalRedeclaration(int x)
{
	int y = x;
	int y = x;
}

int testLocalShadowing(int x)
{
	int y = x;
	{
		// Because this declaration is in an inner
		// scope it should shadow the existing `y`
		// rather than conflcit with it.
		//
		// TODO: It would be reasonable for the
		// compiler to warn on this sort of code.
		//
		int y = x;
	}
}

// Structure fields

struct S
{
	int f;
	float f;
}

// Function parameter list

int testParameterRedeclaration(
	int 	size,
	float 	size)
{
	return size;
}
back to top