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

Support 2024.1 IDEA Version and Fix Minor Error False Positives #166

Merged
merged 1 commit into from
Feb 2, 2024

Conversation

spoage
Copy link
Contributor

@spoage spoage commented Feb 2, 2024

Description

  • Compatibility: upgrade to 2023.3 / 233.2 version
  • Grammar: rules with multidimensional array heads support
  • Grammar: else expressions no longer consider ':=' invalid
  • tests: bump OPA version to v0.61.0

Fixes #165
Fixes #151

Support for idea 2024.1
Grammar: rules with multidimensional array heads support
Grammar: else expressions no longer consider ':=' invalid

Copy link
Member

@anderseknert anderseknert left a comment

Choose a reason for hiding this comment

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

Thanks! Just some nits / questions.

@@ -67,10 +67,10 @@ module ::= package (import| rule)*
package ::= "package" ref
import ::= "import" ref ( "as" var )?
rule ::= "default"? rule-head rule-body*
rule-head ::= var ( "(" rule-args? ")" )? ("[" term "]" )? ( ( ":=" | "=" ) expr )?
rule-head ::= var ( "(" rule-args? ")" )? ("[" term "]" )* ( ( ":=" | "=" ) expr )?
Copy link
Member

Choose a reason for hiding this comment

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

What does this change mean in practice?

Copy link
Contributor Author

@spoage spoage Feb 2, 2024

Choose a reason for hiding this comment

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

It allows multidimensional array/object notation for the rule head, as an alternative to the dot notation. See the added test in the rule_head test file for an example.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, gotcha! Thanks for bearing with me :)

rule-args ::= term ( "," term )*
rule-body ::= else-expr | query-block
else-expr ::= else "=" expr query-block? | else "="? query-block
else-expr ::= else (':=' | '=') expr query-block? | else "="? query-block
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be updated in the last expression too? i.e. the else "="?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps. I couldn't find a test case that I could test it on, so I chose to leave it alone. I can tweak it anyway, if desired?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have replicated the addition to the other expression and added a test to cover it.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks

input.x < input.y
} else := {
true
}
Copy link
Member

Choose a reason for hiding this comment

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

This is assigning a new set containing true as its only item. else := true would probably make more sense here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, good find. Assigning it true was my intent, but I also was trying to keep the test case style in line with the rest in the file and it worked, so I didn't think about it too hard. I'll address this.

* Grammar: multidimensional array rule heads considered valid
* Grammar: else expressions no longer consider ':=' invalid
* tests: bump OPA version to v0.61.0

Signed-off-by: Shane Poage <[email protected]>
@anderseknert
Copy link
Member

Thanks Shane! Much appreciated. Now just to try and figure out how to get this published, as I've never been involved in that before 😅 If you have experience publishing a plugin and could help provide some pointers, hit me up on the OPA Slack!

@anderseknert anderseknert merged commit 63ddf24 into open-policy-agent:master Feb 2, 2024
6 checks passed
@spoage spoage deleted the compatibility-2023-3 branch February 2, 2024 20:00
@vgramer
Copy link
Member

vgramer commented Feb 6, 2024

@spoage Thanks for the work :)

Just a clarification, this PR fixes compatibility for IDEA 2024.1 ( aka 241 in gradle, the new EAP) version on dev was already compatible with version 2023.3 (aka 233 in gradle).

@anderseknert, I have a working PR that fixes the release-note generation and publishing of the plugin... But it is not opened yet as I have weird behavior.
TLDR: the last version on dev should not have been published as tests failed due to missing opa binary.

I will open PR this afternoon or tomorrow.

@anderseknert
Copy link
Member

Ah, very happy to hear that Vincent! 👍 Looking forward to having Rego in my IDEA IDE's once more :)

@vgramer vgramer changed the title Support 2023.3 IDEA Version and Fix Minor Error False Positives Support 2024.1 IDEA Version and Fix Minor Error False Positives Feb 7, 2024
@vgramer vgramer added kind/feature Categorizes issue or PR as related to a new feature area/grammar issue or pr related to the grammar labels Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/grammar issue or pr related to the grammar kind/feature Categorizes issue or PR as related to a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Not compatible with WebStorm 2023.3.3 := not allowed after else keyword
3 participants