mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-27 02:24:15 +03:00
Better error for missing member on circuit init
This commit is contained in:
parent
014959aa24
commit
e7f4a41410
@ -162,9 +162,6 @@ impl<'a> ExpressionVisitor<'a> for TypeChecker<'a> {
|
||||
}
|
||||
|
||||
// Check circuit member types.
|
||||
// TODO: Leo errors for:
|
||||
// - missing members on initialization.
|
||||
// - members that don't exist in the circuit
|
||||
circ.members
|
||||
.iter()
|
||||
.for_each(|CircuitMember::CircuitVariable(name, ty)| {
|
||||
@ -174,9 +171,11 @@ impl<'a> ExpressionVisitor<'a> for TypeChecker<'a> {
|
||||
self.visit_expression(expr, &Some(*ty));
|
||||
}
|
||||
} else {
|
||||
self.handler.emit_err(
|
||||
TypeCheckerError::unknown_sym("circuit member variable", name, name.span()).into(),
|
||||
);
|
||||
self.handler.emit_err(TypeCheckerError::missing_circuit_member(
|
||||
circ.identifier,
|
||||
name,
|
||||
input.span(),
|
||||
));
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -216,7 +216,7 @@ create_messages!(
|
||||
missing_circuit_member {
|
||||
args: (circuit: impl Display, member: impl Display),
|
||||
msg: format!(
|
||||
"Circuit `{circuit}` missing member `{member}`.",
|
||||
"Circuit initialization expression for `{circuit}` is missing member `{member}`.",
|
||||
),
|
||||
help: None,
|
||||
}
|
||||
|
@ -2,4 +2,4 @@
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [ETYC0372006]: Unknown circuit member variable `owner`\n --> compiler-test:5:5\n |\n 5 | owner: address,\n | ^^^^^\n"
|
||||
- "Error [ETYC0372019]: Circuit initialization expression for `Token` is missing member `owner`.\n --> compiler-test:13:12\n |\n 13 | return Token {\n 14 | sender: r0, // This variable should be named `owner`.\n 15 | balance: 0u64,\n 16 | amount: r1,\n 17 | };\n | ^^^^^^\n"
|
||||
|
Loading…
Reference in New Issue
Block a user