difftreelog
feat enable friendly-errors by default
in: master
4 files changed
crates/jrsonnet-evaluator/Cargo.tomldiffbeforeafterboth1[package]2name = "jrsonnet-evaluator"3description = "jsonnet interpreter"4version.workspace = true5repository.workspace = true6authors = ["Yaroslav Bolyukin <iam@lach.pw>"]7license = "MIT"8edition = "2021"910[features]11default = ["explaining-traces", "friendly-errors"]12# Rustc-like trace visualization13explaining-traces = ["annotate-snippets"]14# Allows library authors to throw custom errors15anyhow-error = ["anyhow"]16# Provides helpful explaintations to errors, at cost of adding17# more dependencies and slowing down error path18friendly-errors = ["strsim"]19# Adds ability to build import closure in async20async-import = ["async-trait"]2122# Allows to preserve field order in objects23exp-preserve-order = []24# Implements field destructuring25exp-destruct = ["jrsonnet-parser/exp-destruct"]26# Iteration over objects yields [key, value] elements27exp-object-iteration = []28# Bigint type29exp-bigint = ["num-bigint", "jrsonnet-types/exp-bigint"]3031# Improves performance, and implements some useful things using nightly-only features32nightly = ["hashbrown/nightly"]3334[dependencies]35jrsonnet-interner.workspace = true36jrsonnet-parser.workspace = true37jrsonnet-types.workspace = true38jrsonnet-macros.workspace = true39jrsonnet-gcmodule.workspace = true4041pathdiff = "0.2.1"42hashbrown = "0.13.2"43static_assertions = "1.1"4445rustc-hash = "1.1"4647thiserror = "1.0"4849serde = "1.0"5051anyhow = { version = "1.0", optional = true }52# Friendly errors53strsim = { version = "0.10.0", optional = true }54# Serialized stdlib55bincode = { version = "1.3", optional = true }56# Explaining traces57annotate-snippets = { version = "0.9.1", features = ["color"], optional = true }58# Async imports59async-trait = { version = "0.1.60", optional = true }60# Bigint61num-bigint = { version = "0.4.3", features = ["serde"], optional = true }crates/jrsonnet-evaluator/src/ctx.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/ctx.rs
+++ b/crates/jrsonnet-evaluator/src/ctx.rs
@@ -51,17 +51,6 @@
self.0.sup.as_ref()
}
- #[cfg(not(feature = "friendly-errors"))]
- pub fn binding(&self, name: IStr) -> Result<Thunk<Val>> {
- Ok(self
- .0
- .bindings
- .get(&name)
- .cloned()
- .ok_or(VariableIsNotDefined(name, vec![]))?)
- }
-
- #[cfg(feature = "friendly-errors")]
pub fn binding(&self, name: IStr) -> Result<Thunk<Val>> {
use std::cmp::Ordering;
crates/jrsonnet-evaluator/src/error.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/error.rs
+++ b/crates/jrsonnet-evaluator/src/error.rs
@@ -1,6 +1,7 @@
use std::{
+ cmp::Ordering,
fmt::{Debug, Display},
- path::PathBuf, cmp::Ordering,
+ path::PathBuf,
};
use jrsonnet_gcmodule::Trace;
@@ -79,9 +80,8 @@
if conf < 0.8 {
continue;
}
- if field.as_str() == key.as_str() {
- panic!("looks like string pooling failure, please write any info regarding this crash to https://github.com/CertainLach/jrsonnet/issues/113, thanks!");
- }
+ assert!(field.as_str() != key.as_str(), "looks like string pooling failure, please write any info regarding this crash to https://github.com/CertainLach/jrsonnet/issues/113, thanks!");
+
heap.push((conf, field));
}
heap.sort_by(|a, b| b.0.partial_cmp(&a.0).unwrap_or(Ordering::Equal));
crates/jrsonnet-evaluator/src/evaluate/mod.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/evaluate/mod.rs
+++ b/crates/jrsonnet-evaluator/src/evaluate/mod.rs
@@ -1,4 +1,4 @@
-use std::{cmp::Ordering, rc::Rc};
+use std::rc::Rc;
use jrsonnet_gcmodule::{Cc, Trace};
use jrsonnet_interner::IStr;
@@ -12,7 +12,7 @@
use crate::{
arr::ArrValue,
destructure::evaluate_dest,
- error::{ErrorKind::*, suggest_object_fields},
+ error::{suggest_object_fields, ErrorKind::*},
evaluate::operator::{evaluate_add_op, evaluate_binary_op_special, evaluate_unary_op},
function::{CallLocation, FuncDesc, FuncVal},
throw,