mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-10 13:24:15 +03:00
Implement fix
This commit is contained in:
parent
adb382cb33
commit
9907d89886
@ -322,6 +322,8 @@ impl<'a> StatementVisitor<'a> for TypeChecker<'a> {
|
||||
// If `input.start` is a literal, instantiate it as a value.
|
||||
if let Expression::Literal(literal) = &input.start {
|
||||
input.start_value.replace(Some(Value::from(literal)));
|
||||
} else {
|
||||
self.emit_err(TypeCheckerError::loop_bound_must_be_a_literal(input.start.span()));
|
||||
}
|
||||
|
||||
self.visit_expression(&input.stop, iter_type);
|
||||
@ -329,6 +331,8 @@ impl<'a> StatementVisitor<'a> for TypeChecker<'a> {
|
||||
// If `input.stop` is a literal, instantiate it as a value.
|
||||
if let Expression::Literal(literal) = &input.stop {
|
||||
input.stop_value.replace(Some(Value::from(literal)));
|
||||
} else {
|
||||
self.emit_err(TypeCheckerError::loop_bound_must_be_a_literal(input.stop.span()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -423,4 +423,11 @@ create_messages!(
|
||||
msg: format!("Cannot call a local transition function from a transition function."),
|
||||
help: None,
|
||||
}
|
||||
|
||||
@formatted
|
||||
loop_bound_must_be_a_literal {
|
||||
args: (),
|
||||
msg: format!("Loop bound must be a literal."),
|
||||
help: None,
|
||||
}
|
||||
);
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [ETYC0372049]: Loop bound must be a literal.\n --> compiler-test:12:28\n |\n 12 | for i:u64 in 0u64..amount {\n | ^^^^^^\n"
|
Loading…
Reference in New Issue
Block a user