Skip to content

Commit

Permalink
Automated rollback of commit 7a262a6.
Browse files Browse the repository at this point in the history
*** Reason for rollback ***

Needed to rollback underlying bazelbuild@3774f00

*** Original change description ***

Check for restricted Starlark syntax in REPO.bazel/MODULE.bazel files

No `def`, `if`, etc. allowed. We extract the part of the NodeVisitor in PackageFactory that checks for this into a standalone RestrictedStarlarkSyntaxChecker class and clean up the interface (no need for the Consumer<SyntaxError> stuff if everyone already expects a SyntaxError.Exception for the compilation step anyway).

PiperOrigin-RevId: 553485958
Change-Id: I40cf1aaf3235e781372e47f7a60ea6ab1ba9aecf
  • Loading branch information
brandjon authored and copybara-github committed Aug 3, 2023
1 parent 1929367 commit 1fc72f2
Show file tree
Hide file tree
Showing 9 changed files with 177 additions and 271 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import com.google.devtools.build.lib.cmdline.PackageIdentifier;
import com.google.devtools.build.lib.cmdline.RepositoryName;
import com.google.devtools.build.lib.events.Event;
import com.google.devtools.build.lib.packages.DotBazelFileSyntaxChecker;
import com.google.devtools.build.lib.packages.StarlarkExportable;
import com.google.devtools.build.lib.rules.repository.RepositoryDirectoryValue;
import com.google.devtools.build.lib.server.FailureDetails.ExternalDeps.Code;
Expand Down Expand Up @@ -278,11 +277,10 @@ private ModuleFileGlobals execModuleFile(
ModuleFileGlobals moduleFileGlobals =
new ModuleFileGlobals(builtinModules, moduleKey, registry, ignoreDevDeps);
try (Mutability mu = Mutability.create("module file", moduleKey)) {
new DotBazelFileSyntaxChecker("MODULE.bazel files", /* canLoadBzl= */ false)
.check(starlarkFile);
net.starlark.java.eval.Module predeclaredEnv =
getPredeclaredEnv(moduleFileGlobals, starlarkSemantics);
Program program = Program.compileFile(starlarkFile, predeclaredEnv);
// TODO(wyv): check that `program` has no `def`, `if`, etc
StarlarkThread thread = new StarlarkThread(mu, starlarkSemantics);
if (printIsNoop) {
thread.setPrintHandler((t, msg) -> {});
Expand Down

This file was deleted.

Loading

0 comments on commit 1fc72f2

Please sign in to comment.