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

Comment out unused variables to avoid error for homepage sample #4534

Merged
merged 1 commit into from
Apr 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/website/layouts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ <h2>Declarative Policy</h2>

# Employees can see all pets.
allowed_pets[pet] {
[header, payload, signature] := io.jwt.decode(input.token)
[_, payload, _] := io.jwt.decode(input.token)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove the commented-out lines, please.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok.
I left it there because it will help people to understand the meaning of return values of io.jwt.decode()

Copy link
Contributor Author

@panpan0000 panpan0000 Apr 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now comment line are removed. thanks @srenatus

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 It's a little unfortunate that you cannot do

[_header, payload, _signature] := io.jwt.decode(input.token)

in strict mode.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm.. new syntax(_$variable) learned . thanks .

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah it's valid but it currently won't affect the compiler's strict mode: my example snippet would also be rejected. I think allowing for unused vars if they start with an underscore would perhaps be a nice enhancement.

payload.employee == true
some i
pet := input.pet_list[i]
Expand All @@ -726,7 +726,7 @@ <h2>Declarative Policy</h2>
<button
class="mt-4 btn btn-primary btn-playground"><a
target=”_blank”
href="https://play.openpolicyagent.org/p/c6412EHjS7">Open In Playground
href="https://play.openpolicyagent.org/p/5loFkqN19G">Open In Playground
<img src="/live-blocks/icons/playground-open.svg"
class="launch-playground-icon"></a>
</button>
Expand Down Expand Up @@ -1354,7 +1354,7 @@ <h2>Declarative Policy</h2>

# Employees can see all pets.
allowed_pets[pet] {
[header, payload, signature] := io.jwt.decode(input.token)
[_, payload, _] := io.jwt.decode(input.token)
payload.employee == true
some i
pet := input.pet_list[i]
Expand All @@ -1374,7 +1374,7 @@ <h2>Declarative Policy</h2>
<button
class="mt-4 btn btn-primary btn-playground"><a
target=”_blank”
href="https://play.openpolicyagent.org/p/c6412EHjS7">Open In Playground
href="https://play.openpolicyagent.org/p/5loFkqN19G">Open In Playground
<img src="/live-blocks/icons/playground-open.svg"
class="launch-playground-icon"></a>
</button>
Expand Down Expand Up @@ -1657,4 +1657,4 @@ <h4>CLI and REPL for complete control</h4>
</body>

</html>
{{ end }}
{{ end }}