mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-09-11 13:56:58 +03:00
Better error for missing member on circuit init
This commit is contained in:
parent
91078b5f8e
commit
bec00217cf
@ -159,9 +159,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)| {
|
||||
@ -171,10 +168,10 @@ impl<'a> ExpressionVisitor<'a> for TypeChecker<'a> {
|
||||
self.visit_expression(expr, &Some(*ty));
|
||||
}
|
||||
} else {
|
||||
self.handler.emit_err(TypeCheckerError::unknown_sym(
|
||||
"circuit member variable",
|
||||
self.handler.emit_err(TypeCheckerError::missing_circuit_member(
|
||||
circ.identifier,
|
||||
name,
|
||||
name.span(),
|
||||
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