Skip to content

Commit

Permalink
fix warnings caused by missing spans (#1340)
Browse files Browse the repository at this point in the history
  • Loading branch information
dark64 authored Sep 12, 2023
1 parent 96250e4 commit 89cc999
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
1 change: 1 addition & 0 deletions changelogs/unreleased/1340-dark64
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add missing source information
10 changes: 9 additions & 1 deletion zokrates_analysis/src/variable_write_remover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ impl<'ast> VariableWriteRemover {
.span(span),
ConditionalKind::IfElse,
)
.span(span)
.into(),
Type::Struct(..) => StructExpression::conditional(
BooleanExpression::uint_eq(
Expand All @@ -114,7 +115,6 @@ impl<'ast> VariableWriteRemover {
UExpression::from(i).span(span),
)
.span(span)
.span(span)
.into(),
tail.clone(),
new_expression.clone(),
Expand All @@ -134,6 +134,7 @@ impl<'ast> VariableWriteRemover {
.span(span),
ConditionalKind::IfElse,
)
.span(span)
.into(),
Type::Tuple(..) => TupleExpression::conditional(
BooleanExpression::uint_eq(
Expand Down Expand Up @@ -166,6 +167,7 @@ impl<'ast> VariableWriteRemover {
.span(span),
ConditionalKind::IfElse,
)
.span(span)
.into(),
Type::FieldElement => FieldElementExpression::conditional(
BooleanExpression::uint_eq(
Expand Down Expand Up @@ -198,6 +200,7 @@ impl<'ast> VariableWriteRemover {
.span(span),
ConditionalKind::IfElse,
)
.span(span)
.into(),
Type::Boolean => BooleanExpression::conditional(
BooleanExpression::uint_eq(
Expand Down Expand Up @@ -230,6 +233,7 @@ impl<'ast> VariableWriteRemover {
.span(span),
ConditionalKind::IfElse,
)
.span(span)
.into(),
Type::Uint(..) => UExpression::conditional(
BooleanExpression::uint_eq(
Expand Down Expand Up @@ -262,10 +266,12 @@ impl<'ast> VariableWriteRemover {
.span(span),
ConditionalKind::IfElse,
)
.span(span)
.into(),
})
.collect::<Vec<_>>(),
)
.span(span)
.annotate(ArrayType::new(inner_ty.clone(), size))
.into()
}
Expand Down Expand Up @@ -394,6 +400,7 @@ impl<'ast> VariableWriteRemover {
})
.collect(),
)
.span(span)
.annotate(members)
.into(),
_ => unreachable!(),
Expand Down Expand Up @@ -512,6 +519,7 @@ impl<'ast> VariableWriteRemover {
})
.collect(),
)
.span(span)
.annotate(tuple_ty)
.into(),
_ => unreachable!(),
Expand Down
3 changes: 2 additions & 1 deletion zokrates_analysis/src/zir_propagation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,8 @@ impl<'ast, T: Field> ResultFolder<'ast, T> for ZirPropagator<'ast, T> {
))
} else {
Ok(ConditionalOrExpression::Conditional(
ConditionalExpression::new(condition, consequence, alternative),
ConditionalExpression::new(condition, consequence, alternative)
.span(e.span),
))
}
}
Expand Down
10 changes: 5 additions & 5 deletions zokrates_core/src/semantics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,8 @@ impl<'ast, T: Field> Checker<'ast, T> {
let decl_v = DeclarationVariable::new(
self.id_in_this_scope(arg.id.value.id),
decl_ty.clone(),
);
)
.with_span(arg.id.span().in_module(module_id));

let is_mutable = arg.id.value.is_mutable;

Expand Down Expand Up @@ -2162,10 +2163,9 @@ impl<'ast, T: Field> Checker<'ast, T> {
span: Some(assignee.span().in_module(module_id)),
message: format!("Assignment to an immutable variable `{}`", variable_name),
}),
_ => Ok(TypedAssignee::Identifier(Variable::new(
info.id,
info.ty.clone(),
))),
_ => Ok(TypedAssignee::Identifier(
Variable::new(info.id, info.ty.clone()).with_span(span),
)),
},
None => Err(ErrorInner {
span: Some(assignee.span().in_module(module_id)),
Expand Down

0 comments on commit 89cc999

Please sign in to comment.