git.delta.rocks / jrsonnet / refs/commits / f3a68fbe7763

difftreelog

fix(evaluator) restrict standalone `super` usage

Лач2020-06-25parent: #9b33194.patch.diff
in: master

2 files changed

modifiedcrates/jsonnet-evaluator/src/error.rsdiffbeforeafterboth
before · crates/jsonnet-evaluator/src/error.rs
1use crate::ValType;2use jsonnet_parser::LocExpr;34#[derive(Debug)]5pub enum Error {6	VariableIsNotDefined(String),7	TypeMismatch(&'static str, Vec<ValType>, ValType),8	NoSuchField(String),910	UnknownVariable(String),1112	UnknownFunctionParameter(String),13	BindingParameterASecondTime(String),14	TooManyArgsFunctionHas(usize),15	FunctionParameterNotBoundInCall(String),1617	UndefinedExternalVariable(String),1819	FieldMustBeStringGot(ValType),2021	AttemptedIndexAnArrayWithString(String),22	ValueIndexMustBeTypeGot(ValType, ValType, ValType),23	CantIndexInto(ValType),2425	RuntimeError(String),26	StackOverflow,27	FractionalIndex,28	DivisionByZero,29}3031#[derive(Clone, Debug)]32pub struct StackTraceElement(pub LocExpr, pub String);33#[derive(Debug)]34pub struct StackTrace(pub Vec<StackTraceElement>);3536#[derive(Debug)]37pub struct LocError(pub Error, pub StackTrace);38pub type Result<V> = std::result::Result<V, LocError>;
modifiedcrates/jsonnet-evaluator/src/evaluate.rsdiffbeforeafterboth
--- a/crates/jsonnet-evaluator/src/evaluate.rs
+++ b/crates/jsonnet-evaluator/src/evaluate.rs
@@ -811,5 +811,6 @@
 			file_path.push(path);
 			Val::Str(with_state(|s| s.import_file_str(&file_path))?)
 		}
+		Literal(LiteralType::Super) => return create_error(crate::error::Error::StandaloneSuper),
 	})
 }