Skip to content

Commit

Permalink
fix: rename variable to local
Browse files Browse the repository at this point in the history
  • Loading branch information
CertainLach committed Aug 30, 2024
1 parent 761e429 commit a31a8ef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions crates/jrsonnet-evaluator/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ pub(crate) fn format_found(list: &[IStr], what: &str) -> String {
return String::new();
}
let mut out = String::new();
out.push_str("\nThere is ");
out.push_str("\nThere ");
if list.len() > 1 {
out.push_str("are ");
} else {
out.push_str("is a ");
}
out.push_str(what);
if list.len() > 1 {
out.push('s');
Expand Down Expand Up @@ -133,7 +138,7 @@ pub enum ErrorKind {
#[error("assert failed: {}", format_empty_str(.0))]
AssertionFailed(IStr),

#[error("variable is not defined: {0}{}", format_found(.1, "variable"))]
#[error("local is not defined: {0}{}", format_found(.1, "local"))]
VariableIsNotDefined(IStr, Vec<IStr>),
#[error("duplicate local var: {0}")]
DuplicateLocalVar(IStr),
Expand Down
2 changes: 1 addition & 1 deletion crates/jrsonnet-evaluator/src/evaluate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ pub fn evaluate(ctx: Context, expr: &LocExpr) -> Result<Val> {
UnaryOp(o, v) => evaluate_unary_op(*o, &evaluate(ctx, v)?)?,
Var(name) => in_frame(
CallLocation::new(&loc),
|| format!("variable <{name}> access"),
|| format!("local <{name}> access"),
|| ctx.binding(name.clone())?.evaluate(),
)?,
Index { indexable, parts } => ensure_sufficient_stack(|| {
Expand Down

0 comments on commit a31a8ef

Please sign in to comment.