Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error messages on ErgoTree evaluation #720

Merged
merged 74 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
2428e3e
make Evaluable::eval's environment a mutable ref;
greenhat Jul 17, 2023
0e819e9
add EvalError::WrappedWithEnvError with evaluation env attached;
greenhat Jul 18, 2023
65b129d
draft SourceSpan and SourceSpanWrapper;
greenhat Jul 19, 2023
35dd5ac
enrich Append eval error with source span;
greenhat Jul 21, 2023
a96a7c9
Move source_span module to the ergotree-ir crate root;
greenhat Jul 24, 2023
eda5e27
draft pretty printer types and smoke test;
greenhat Jul 24, 2023
8b3d624
draft Print trait IR nodes;
greenhat Jul 24, 2023
7a562f7
draft Printer trait tracking current position and indentation level;
greenhat Aug 1, 2023
7f28707
draft Print impl for Expr;
greenhat Aug 2, 2023
868076b
draft the expr printing and running eval again in reduce_to_crypto;
greenhat Aug 2, 2023
e46c92e
extract EvalError into a separate module;
greenhat Aug 3, 2023
e20f087
merge wrapped EvalError variants into one;
greenhat Aug 3, 2023
01cb82f
extract EvalErrorDetails and add wrap_with_src for EvalError;
greenhat Aug 3, 2023
c99f6ce
impl Print for BlockValue;
greenhat Aug 4, 2023
c10d084
formatting;
greenhat Aug 4, 2023
0eb274b
impl Print for ValDef and Constant;
greenhat Aug 7, 2023
8bb1181
impl Print for ValUse, fix indentations and new lines in pretty printer;
greenhat Aug 7, 2023
c6b94db
Rename Span to SourceSpan and switch it to offset+length based repres…
greenhat Aug 8, 2023
be311ac
impl Print for BinOp;
greenhat Aug 8, 2023
a948266
fix nested error wrapping, add division by zero eval test;
greenhat Aug 8, 2023
d353c71
fix spanned Expr construction in Print implementations;
greenhat Aug 8, 2023
e320143
rework wrapped EvalError variants, add custom Display impl for wrappe…
greenhat Sep 22, 2023
bf365dd
add source span test eval error;
greenhat Aug 9, 2023
9f8dfea
impl Print for GlobalVars;
greenhat Aug 11, 2023
e26d18e
impl pretty printing for ByIndex and add out of bounds error test;
greenhat Sep 22, 2023
955e751
add span check in pretty error tests;
greenhat Aug 15, 2023
a5e40f7
impl Display impl for Constant (primitive and composite types);
greenhat Aug 15, 2023
cf0efe3
Display impl for SType;
greenhat Aug 16, 2023
da54af0
implement Display for all Literal variants;
greenhat Aug 18, 2023
22ca326
set empty source span for IR nodes that can only fail at runtime due …
greenhat Aug 21, 2023
e355048
add details to error messages in EvalError variants;
greenhat Aug 21, 2023
8cf9c87
fix formatting;
greenhat Aug 21, 2023
922e2ad
update compiler tests expected results
greenhat Aug 21, 2023
54412d4
Wrap SubstConstants in Spanned;
greenhat Aug 22, 2023
c2747ad
Wrap ByteArrayToLong in Spanned;
greenhat Aug 22, 2023
ae4fd0f
Wrap ByteArrayToBigInt in Spanned;
greenhat Aug 22, 2023
afd73c6
wrap MethodCall in Spanned;
greenhat Aug 22, 2023
7ff21c0
wrap PropertyCall in Spanned;
greenhat Aug 22, 2023
47960ba
wrap Negation in Spanned
greenhat Aug 22, 2023
e9e24e1
wrap OptionGet in Spanned;
greenhat Aug 22, 2023
d8b4384
wrap OptionIsDefined in Spanned;
greenhat Aug 22, 2023
b0ef00f
wrap OptionGetOrElse in Spanned;
greenhat Aug 22, 2023
cc905f5
wrap ExtractRegisterAs in Spanned;
greenhat Aug 22, 2023
a2f2a6c
wrap Slice in Spanned;
greenhat Aug 22, 2023
984dbe6
wrap Fold in Spanned;
greenhat Aug 22, 2023
cbbc6d5
wrap Filter, Fold and ForAll in Spanned;
greenhat Aug 22, 2023
99489da
wrap SelectField in Spanned;
greenhat Aug 22, 2023
25c24f8
wrap SelectField and GetVar in Spanned;
greenhat Aug 22, 2023
dd6ac14
wrap Deserialize* into Spanned;
greenhat Aug 22, 2023
986fc41
wrap TreeLookup in Spanned;
greenhat Aug 22, 2023
1e282b6
fix expected formatting in pretty printer tests;
greenhat Aug 22, 2023
9eb85a1
fix formatting;
greenhat Aug 22, 2023
6bb6761
update expected source spans in binop pretty print test;
greenhat Aug 23, 2023
91e2a0f
skip ConstPlaceholder in pretty printer;
greenhat Aug 23, 2023
5b3873b
fix source span in expected pretty printer test;
greenhat Aug 23, 2023
824ed24
move Print trait and implementations into a separate module;
greenhat Sep 4, 2023
40301df
add EIP23 refresh contract as pretty printer test;
greenhat Sep 5, 2023
ec07000
add Print impl for various IR nodes and print EIP23 refresh contract;
greenhat Sep 6, 2023
b55a0b3
add EIP23 update contract as pretty printer test;
greenhat Sep 7, 2023
aa23f31
add EIP23 ballot contract as pretty printer test;
greenhat Sep 7, 2023
1456b1d
add EIP23 oracle contract as pretty printer test;
greenhat Sep 7, 2023
b81978c
add ageusd bank contract to pretty printer test
greenhat Sep 8, 2023
91c3cf4
add ageusd update contract to pretty printer test;
greenhat Sep 8, 2023
b1e4091
add eip14 amm pool and swap contracts to pretty printer tests;
greenhat Sep 11, 2023
4d09d26
add the rest of amm_conc_pool_* EIP22 auction contracts to the pretty…
greenhat Sep 13, 2023
d1b0e56
add doc comment;
greenhat Sep 13, 2023
0eefaef
pretty printer for ByteArrayTo* IR nodes;
greenhat Sep 14, 2023
7c99195
impl Print for LongToByteArray and CalcSha256;
greenhat Sep 19, 2023
1f7a246
implmennt pretty printing for And, Or, LogicalNot, Xor, SubstConstant…
greenhat Sep 20, 2023
b049864
fix build after rebase;
greenhat Sep 22, 2023
0bd29ad
implement pretty printing for BitInversion, OptionGetOrElse, Slice, F…
greenhat Sep 22, 2023
b6e6084
impl Print for DeserializeRegister and DeserializeContext
greenhat Sep 26, 2023
ee9b159
code formatting
greenhat Sep 27, 2023
3a62672
impl pretty printer for MultiplyGroup, Exponentiate, XorOf, TreeLooku…
greenhat Sep 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
wrap SelectField in Spanned;
  • Loading branch information
greenhat committed Sep 22, 2023
commit 99489da15d14b0eed371e5febc24a68dde32442a
4 changes: 2 additions & 2 deletions ergotree-ir/src/mir/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ pub enum Expr {
/// Tests whether a predicate holds for all elements of this collection.
ForAll(Spanned<ForAll>),
/// Tuple field access
SelectField(SelectField),
SelectField(Spanned<SelectField>),
/// Bool to SigmaProp
BoolToSigmaProp(BoolToSigmaProp),
/// Upcast numeric value
Expand Down Expand Up @@ -254,7 +254,7 @@ impl Expr {
Expr::OptionGet(v) => v.expr().tpe(),
Expr::ExtractRegisterAs(v) => v.expr().tpe(),
Expr::Fold(v) => v.expr().tpe(),
Expr::SelectField(v) => v.tpe(),
Expr::SelectField(v) => v.expr().tpe(),
Expr::ExtractAmount(v) => v.tpe(),
Expr::And(v) => v.tpe(),
Expr::Or(v) => v.tpe(),
Expand Down
2 changes: 1 addition & 1 deletion ergotree-ir/src/serialization/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ impl Expr {
OpCode::VAL_DEF => Ok(Expr::ValDef(ValDef::sigma_parse(r)?.into())),
OpCode::VAL_USE => Ok(Expr::ValUse(ValUse::sigma_parse(r)?)),
ExtractAmount::OP_CODE => Ok(Expr::ExtractAmount(ExtractAmount::sigma_parse(r)?)),
OpCode::SELECT_FIELD => Ok(Expr::SelectField(SelectField::sigma_parse(r)?)),
OpCode::SELECT_FIELD => Ok(Expr::SelectField(SelectField::sigma_parse(r)?.into())),
OpCode::CALC_BLAKE2B256 => Ok(CalcBlake2b256::sigma_parse(r)?.into()),
CalcSha256::OP_CODE => Ok(CalcSha256::sigma_parse(r)?.into()),
And::OP_CODE => Ok(And::sigma_parse(r)?.into()),
Expand Down
4 changes: 3 additions & 1 deletion ergotree-ir/src/source_span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use crate::mir::option_get::OptionGet;
use crate::mir::option_get_or_else::OptionGetOrElse;
use crate::mir::option_is_defined::OptionIsDefined;
use crate::mir::property_call::PropertyCall;
use crate::mir::select_field::SelectField;
use crate::mir::subst_const::SubstConstants;
use crate::mir::val_def::ValDef;

Expand Down Expand Up @@ -107,6 +108,7 @@ into_expr!(Map);
into_expr!(Filter);
into_expr!(Exists);
into_expr!(ForAll);
into_expr!(SelectField);

impl<T> From<T> for Spanned<T> {
fn from(v: T) -> Self {
Expand Down Expand Up @@ -170,7 +172,7 @@ impl Expr {
Expr::Filter(op) => op.source_span,
Expr::Exists(op) => op.source_span,
Expr::ForAll(op) => op.source_span,
Expr::SelectField(_) => todo!(),
Expr::SelectField(op) => op.source_span,
Expr::BoolToSigmaProp(_) => SourceSpan::empty(),
Expr::Upcast(_) => SourceSpan::empty(),
Expr::Downcast(_) => SourceSpan::empty(),
Expand Down