Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

float a=a; #153

Closed
laurentlb opened this issue Oct 13, 2022 · 1 comment
Closed

float a=a; #153

laurentlb opened this issue Oct 13, 2022 · 1 comment

Comments

@laurentlb
Copy link
Owner

ttg reported on Discord:

I run into trouble with it after using this idiom in my glsls: float a=a;
Reusing the variable in an inner scope so it can be modified and revert to its old value after that scope closes.

We could need to update our scope resolution to allow this.

It's unclear what the behavior in HLSL is (I wouldn't be surprised if it was treated as a circular reference).

@laurentlb
Copy link
Owner Author

laurentlb commented Oct 13, 2022

The spec has interesting test cases related to scoping:

int x = 1;
{
  int x = 2, y = x; // y is initialized to 2
}

struct S{ int x; };
{
  S S = S(0); // 'S' is only visible as a struct and constructor
  S; // 'S' is now visible as a variable
}

int x = x; // Error if x has not been previously defined.
  // If the previous definition of x was in this
  // same scope, this causes a redeclaration error.

int f( /* nested scope begins here */ int k) {
  int k = k + 3; // redeclaration error of the name k
}

int f(int k)
{
  {
  int k = k + 3; // 2nd k is parameter, initializing nested first k
  int m = k; // use of new k, which is hiding the parameter
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant