Skylark: path in load statement either has to be absolute or has to have exactly one segment.
--
MOS_MIGRATED_REVID=87234901
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/LoadStatement.java b/src/main/java/com/google/devtools/build/lib/syntax/LoadStatement.java
index 6873995..9c59989 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/LoadStatement.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/LoadStatement.java
@@ -24,6 +24,8 @@
*/
public final class LoadStatement extends Statement {
+ public static final String PATH_ERROR_MSG = "Path '%s' is not valid. "
+ + "It should either start with a slash or refer to a file in the current directory.";
private final ImmutableList<Ident> symbols;
private final PathFragment importPath;
@@ -70,6 +72,9 @@
@Override
void validate(ValidationEnvironment env) throws EvalException {
+ if (!importPath.isAbsolute() && importPath.segmentCount() > 1) {
+ throw new EvalException(getLocation(), String.format(PATH_ERROR_MSG, importPath));
+ }
// TODO(bazel-team): implement semantical check.
for (Ident symbol : symbols) {
env.update(symbol.getName(), SkylarkType.UNKNOWN, getLocation());