diff --git a/build/generate-extended-cases/extended_cases.go b/build/generate-extended-cases/extended_cases.go index af958c20d2..b2e4cdf243 100644 --- a/build/generate-extended-cases/extended_cases.go +++ b/build/generate-extended-cases/extended_cases.go @@ -179,15 +179,10 @@ func LoadIrExtendedTestCasesFiltered(filters ...Filters) ([]ExtendedSet, error) continue } - // TODO: drop once future.keywords.not is enabled by default - caps := ast.CapabilitiesForThisVersion() - caps.FutureKeywords = append(caps.FutureKeywords, "not") - opts := []func(*rego.Rego){ rego.Target(pluginName), rego.Query(tc.Query), rego.SetRegoVersion(ast.RegoV1), - rego.Capabilities(caps), } for i := range tc.Modules { opts = append(opts, rego.Module(fmt.Sprintf("module-%d.rego", i), tc.Modules[i])) diff --git a/capabilities.json b/capabilities.json index b47b68d612..07b0eb9507 100644 --- a/capabilities.json +++ b/capabilities.json @@ -4934,6 +4934,9 @@ } } ], + "future_keywords": [ + "not" + ], "wasm_abi_versions": [ { "version": 1, diff --git a/cmd/capabilities_test.go b/cmd/capabilities_test.go index c3346d9a18..cc3b9dfda2 100644 --- a/cmd/capabilities_test.go +++ b/cmd/capabilities_test.go @@ -94,7 +94,7 @@ func TestCapabilitiesCurrent(t *testing.T) { ast.FeatureTemplateStrings, }, expFutureKeywords: []string{ - // "not", // TODO: enable once future.keywords.not is enabled by default + "not", }, }, { @@ -112,7 +112,7 @@ func TestCapabilitiesCurrent(t *testing.T) { "every", "contains", "if", - // "not", // TODO: enable once future.keywords.not is enabled by default + "not", }, }, } diff --git a/internal/planner/planner_test.go b/internal/planner/planner_test.go index 44e00f490e..a327e4b874 100644 --- a/internal/planner/planner_test.go +++ b/internal/planner/planner_test.go @@ -405,16 +405,7 @@ q = 2`, modules := make([]*ast.Module, len(tc.modules)) for i := range modules { file := fmt.Sprintf("module-%d.rego", i) - - // TODO: drop once future.keywords.not is enabled by default - caps := ast.CapabilitiesForThisVersion() - caps.FutureKeywords = append(caps.FutureKeywords, "not") - - opts := ast.ParserOptions{ - AllFutureKeywords: true, - Capabilities: caps, - } - + opts := ast.ParserOptions{AllFutureKeywords: true} m, err := ast.ParseModuleWithOpts(file, tc.modules[i], opts) if err != nil { t.Fatal(err) diff --git a/v1/ast/capabilities.go b/v1/ast/capabilities.go index b9c87b7f47..5b8aa0bdc8 100644 --- a/v1/ast/capabilities.go +++ b/v1/ast/capabilities.go @@ -147,11 +147,6 @@ func CapabilitiesForThisVersion(opts ...CapabilitiesOption) *Capabilities { switch co.regoVersion { case RegoV0, RegoV0CompatV1: for kw := range allFutureKeywords { - // TODO: drop once future.keywords.not is enabled by default - if kw == "not" { - continue - } - f.FutureKeywords = append(f.FutureKeywords, kw) } @@ -164,11 +159,6 @@ func CapabilitiesForThisVersion(opts ...CapabilitiesOption) *Capabilities { } default: for kw := range futureKeywords { - // TODO: drop once future.keywords.not is enabled by default - if kw == "not" { - continue - } - f.FutureKeywords = append(f.FutureKeywords, kw) } diff --git a/v1/ast/compile_test.go b/v1/ast/compile_test.go index e22b098ef3..07fd683220 100644 --- a/v1/ast/compile_test.go +++ b/v1/ast/compile_test.go @@ -12990,11 +12990,9 @@ func TestCompilerCopiesTemplateStrings(t *testing.T) { } } -// TODO: For readability, update AST assertions to use parsed expected module (parser update required) func TestCompilerNotImport(t *testing.T) { - // TODO: drop once future.keywords.not is enabled by default popts := ParserOptions{ - Capabilities: CapabilitiesForThisVersion().withFutureKeyword("not"), + Capabilities: CapabilitiesForThisVersion(), FutureKeywords: []string{"not"}, } @@ -14104,7 +14102,7 @@ func TestCompilerNotImport(t *testing.T) { c := NewCompiler() c.Compile(map[string]*Module{"mod.rego": MustParseModuleWithOpts(tc.module, ParserOptions{ - Capabilities: CapabilitiesForThisVersion().withFutureKeyword("not"), + Capabilities: CapabilitiesForThisVersion(), })}) if len(tc.expErrs) > 0 { @@ -14127,9 +14125,3 @@ func TestCompilerNotImport(t *testing.T) { }) } } - -// TODO: drop once future.keywords.not is enabled by default -func (c *Capabilities) withFutureKeyword(kw string) *Capabilities { - c.FutureKeywords = append(c.FutureKeywords, kw) - return c -} diff --git a/v1/ast/parser_test.go b/v1/ast/parser_test.go index 38acda00df..17584b02fa 100644 --- a/v1/ast/parser_test.go +++ b/v1/ast/parser_test.go @@ -2908,8 +2908,7 @@ func TestImport(t *testing.T) { func TestFutureImports(t *testing.T) { assertParseErrorContains(t, "future", "import future", "invalid import, must be `future.keywords`") assertParseErrorContains(t, "future.a", "import future.a", "invalid import, must be `future.keywords`") - assertParseErrorContains(t, "unknown keyword", "import future.keywords.xyz", "unexpected keyword, must be one of [contains every if in not]", - ParserOptions{Capabilities: CapabilitiesForThisVersion().withFutureKeyword("not")}) // TODO: drop once future.keywords.not is enabled by default + assertParseErrorContains(t, "unknown keyword", "import future.keywords.xyz", "unexpected keyword, must be one of [contains every if in not]") assertParseErrorContains(t, "all keyword import + alias", "import future.keywords as xyz", "`future` imports cannot be aliased") assertParseErrorContains(t, "keyword import + alias", "import future.keywords.in as xyz", "`future` imports cannot be aliased") @@ -9476,8 +9475,7 @@ func TestNotImport(t *testing.T) { for _, tc := range tests { t.Run(tc.note, func(t *testing.T) { - mod, err := ParseModuleWithOpts("", tc.module, - ParserOptions{Capabilities: CapabilitiesForThisVersion().withFutureKeyword("not")}) // TODO: drop once future.keywords.not is enabled by default + mod, err := ParseModule("", tc.module) if tc.expErr != "" { if err == nil { diff --git a/v1/format/format_test.go b/v1/format/format_test.go index f9121bae75..17613cb383 100644 --- a/v1/format/format_test.go +++ b/v1/format/format_test.go @@ -118,13 +118,8 @@ func TestFormatV0Source(t *testing.T) { t.Fatalf("Failed to read expected rego source: %v", err) } - // TODO: drop once future.keywords.not is enabled by default - caps := ast.CapabilitiesForThisVersion(ast.CapabilitiesRegoVersion(ast.RegoV0)) - caps.FutureKeywords = append(caps.FutureKeywords, "not") - popts := ast.ParserOptions{ - RegoVersion: ast.RegoV0, - Capabilities: caps, + RegoVersion: ast.RegoV0, } opts := Opts{ RegoVersion: ast.RegoV0, @@ -175,13 +170,8 @@ func TestFormatV1Source(t *testing.T) { t.Fatalf("Failed to read expected rego source: %v", err) } - // TODO: drop once future.keywords.not is enabled by default - caps := ast.CapabilitiesForThisVersion(ast.CapabilitiesRegoVersion(ast.RegoV1)) - caps.FutureKeywords = append(caps.FutureKeywords, "not") - popts := ast.ParserOptions{ - RegoVersion: ast.RegoV1, - Capabilities: caps, + RegoVersion: ast.RegoV1, } opts := Opts{ RegoVersion: ast.RegoV1, @@ -242,23 +232,14 @@ func TestFormatV0SourceToRegoV1(t *testing.T) { } } - // TODO: drop once future.keywords.not is enabled by default - caps := ast.CapabilitiesForThisVersion(ast.CapabilitiesRegoVersion(ast.RegoV1)) - caps.FutureKeywords = append(caps.FutureKeywords, "not") - sourceOpts := Opts{ RegoVersion: ast.RegoV0CompatV1, // Target syntax is v0 compat v1 ParserOptions: &ast.ParserOptions{ - RegoVersion: ast.RegoV0, // Original syntax is v0 - Capabilities: caps, + RegoVersion: ast.RegoV0, // Original syntax is v0 }, } targetOpts := Opts{ RegoVersion: ast.RegoV0CompatV1, // Target syntax is v0 compat v1 - ParserOptions: &ast.ParserOptions{ - RegoVersion: ast.RegoV0CompatV1, - Capabilities: caps, - }, } if errorExpected { @@ -281,7 +262,7 @@ func TestFormatV0SourceToRegoV1(t *testing.T) { t.Fatalf("Expected formatted bytes to equal expected bytes but differed near line %d / byte %d (got: %q, expected: %q):\n%s", ln, at, formatted[at], expected[at], prefixWithLineNumbers(formatted)) } - if _, err := ast.ParseModuleWithOpts(rego+".tmp", string(formatted), ast.ParserOptions{RegoVersion: ast.RegoV0CompatV1, Capabilities: caps}); err != nil { + if _, err := ast.ParseModule(rego+".tmp", string(formatted)); err != nil { t.Fatalf("Failed to parse formatted bytes: %v", err) } @@ -773,12 +754,6 @@ a[_x[y][[z, w]]]`, }`, ast.ParserOptions{ FutureKeywords: []string{"not"}, - Capabilities: func() *ast.Capabilities { - // TODO: drop once future.keywords.not is enabled by default - caps := ast.CapabilitiesForThisVersion() - caps.FutureKeywords = append(caps.FutureKeywords, "not") - return caps - }(), }), expected: `package test @@ -797,12 +772,6 @@ p { }`, ast.ParserOptions{ FutureKeywords: []string{"not"}, - Capabilities: func() *ast.Capabilities { - // TODO: drop once future.keywords.not is enabled by default - caps := ast.CapabilitiesForThisVersion() - caps.FutureKeywords = append(caps.FutureKeywords, "not") - return caps - }(), }), expected: `package test @@ -822,11 +791,6 @@ p if { }`, ast.ParserOptions{ FutureKeywords: []string{"not"}, - Capabilities: func() *ast.Capabilities { - caps := ast.CapabilitiesForThisVersion() - caps.FutureKeywords = append(caps.FutureKeywords, "not") - return caps - }(), }), expected: `package test @@ -849,11 +813,6 @@ p if { }`, ast.ParserOptions{ FutureKeywords: []string{"not"}, - Capabilities: func() *ast.Capabilities { - caps := ast.CapabilitiesForThisVersion() - caps.FutureKeywords = append(caps.FutureKeywords, "not") - return caps - }(), }), expected: `package test @@ -876,11 +835,6 @@ p if { }`, ast.ParserOptions{ FutureKeywords: []string{"not"}, - Capabilities: func() *ast.Capabilities { - caps := ast.CapabilitiesForThisVersion() - caps.FutureKeywords = append(caps.FutureKeywords, "not") - return caps - }(), }), expected: `package test diff --git a/v1/topdown/exported_test.go b/v1/topdown/exported_test.go index 3e599e835c..6686641d43 100644 --- a/v1/topdown/exported_test.go +++ b/v1/topdown/exported_test.go @@ -141,10 +141,6 @@ func testRun(t *testing.T, tc cases.TestCase, opts ...testOpt) { modules[fmt.Sprintf("test-%d.rego", i)] = module } - // TODO: drop once future.keywords.not is enabled by default - tos.parserOptions.Capabilities = ast.CapabilitiesForThisVersion(ast.CapabilitiesRegoVersion(tos.parserOptions.RegoVersion)) - tos.parserOptions.Capabilities.FutureKeywords = append(tos.parserOptions.Capabilities.FutureKeywords, "not") - compiler := ast.MustCompileModulesWithOpts(modules, ast.CompileOpts{ ParserOptions: tos.parserOptions, }) diff --git a/v1/topdown/topdown_partial_test.go b/v1/topdown/topdown_partial_test.go index 8d3e48f80e..98e299a82b 100644 --- a/v1/topdown/topdown_partial_test.go +++ b/v1/topdown/topdown_partial_test.go @@ -5904,12 +5904,7 @@ func TestTopDownPartialEvalNegation(t *testing.T) { variants := map[string]ast.ParserOptions{ "not": {}, "not-body": func() ast.ParserOptions { - // TODO: drop once future.keywords.not is enabled by default - caps := ast.CapabilitiesForThisVersion() - caps.FutureKeywords = append(caps.FutureKeywords, "not") - return ast.ParserOptions{ - Capabilities: caps, FutureKeywords: []string{"not"}, } }(),