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

Fix warnings caused by missing spans #1340

Merged
merged 3 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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