-
Notifications
You must be signed in to change notification settings - Fork 37
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
Unused output variable #60
Labels
Comments
anderseknert
changed the title
Extended check for unused variables
Unused output variable
Aug 10, 2023
Adding to this: allow if {
some i, x in input.message
} Both |
anderseknert
added a commit
that referenced
this issue
Jul 17, 2024
One of the rules I've wanted since the project was started, but not until now would this have been wildly expensive to add. With the recent fixes that allow us to reuse the result of `walk`ing the AST, that's no longer the case. Still, this required quite some time and effort to get right! NOTE: this rule currently only considers output variables as found in references, i.e. `x` in `input[x]` and NOT `x` in `some x, _ in input`. While that would be easy to add, I'm not sure if those are really "output variables" or should be considered as such... 🤔 or if we should just have another rules for "unused iteration variable" or something like that. Either way, this is a big step forward! Fixes #60 Signed-off-by: Anders Eknert <anders@styra.com>
srenatus
pushed a commit
to srenatus/regal
that referenced
this issue
Oct 1, 2024
One of the rules I've wanted since the project was started, but not until now would this have been wildly expensive to add. With the recent fixes that allow us to reuse the result of `walk`ing the AST, that's no longer the case. Still, this required quite some time and effort to get right! NOTE: this rule currently only considers output variables as found in references, i.e. `x` in `input[x]` and NOT `x` in `some x, _ in input`. While that would be easy to add, I'm not sure if those are really "output variables" or should be considered as such... 🤔 or if we should just have another rules for "unused iteration variable" or something like that. Either way, this is a big step forward! Fixes StyraInc#60 Signed-off-by: Anders Eknert <anders@styra.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
foo { some x input[x] }
Even in strict mode, OPA considers
x
to be "used", as it's referenced somewhere. Howver, unlessx
is referenced later in the rule (or in the rule head) it's not really used, and the above could be replaced by:Or
The text was updated successfully, but these errors were encountered: