mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
genpolicy tweaks (#141)
Allow `import input` instead of erroring out. This import is redundant and has no effect. Emit `print` messages to stderr onstead of stdout. Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
committed by
GitHub
parent
3b2e639918
commit
13eb06e4be
@@ -35,7 +35,7 @@ fn print(span: &Span, _params: &[Ref<Expr>], args: &[Value], _strict: bool) -> R
|
||||
}
|
||||
|
||||
if !msg.is_empty() {
|
||||
println!("{}", &msg[1..]);
|
||||
eprintln!("{}", &msg[1..]);
|
||||
}
|
||||
Ok(Value::Bool(true))
|
||||
}
|
||||
|
||||
@@ -3359,11 +3359,22 @@ impl Interpreter {
|
||||
Expr::String(s) => s.text(),
|
||||
_ => "",
|
||||
},
|
||||
Expr::Var(v) if v.text() == "input" => {
|
||||
// Warn redundant import of input. Ignore it.
|
||||
eprintln!(
|
||||
"{}",
|
||||
import.refr.span().error("redundant import of `input`")
|
||||
);
|
||||
continue;
|
||||
}
|
||||
_ => "",
|
||||
},
|
||||
};
|
||||
if target.is_empty() {
|
||||
bail!(import.refr.span().error("invalid ref in import"));
|
||||
bail!(import
|
||||
.refr
|
||||
.span()
|
||||
.message("warning", "invalid ref in import"));
|
||||
}
|
||||
self.imports
|
||||
.insert(module_path.clone() + "." + target, import.refr.clone());
|
||||
|
||||
@@ -71,3 +71,11 @@ cases:
|
||||
import foo
|
||||
query: data
|
||||
error: "import path must begin with one of"
|
||||
|
||||
- note: redundant import input
|
||||
modules:
|
||||
- |
|
||||
package test
|
||||
import input
|
||||
query: data.test
|
||||
want_result: {}
|
||||
|
||||
Reference in New Issue
Block a user