mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-25 11:12:48 +03:00
Merge #674
674: implicit value at start of array failing fix r=collinc97 a=gluax Resolves #607. Co-authored-by: gluax <jonathan.t.pavlik@gmail.com>
This commit is contained in:
commit
4253ac9133
@ -114,7 +114,28 @@ impl<'a> FromAst<'a, leo_ast::ArrayInlineExpression> for ArrayInlineExpression<'
|
||||
}
|
||||
};
|
||||
|
||||
// If we still don't know the type iterate through processing to get a type.
|
||||
// Once we encouter the type break the loop so we process as little as possible.
|
||||
if expected_item.is_none() {
|
||||
for expr in value.elements.iter() {
|
||||
expected_item = match expr {
|
||||
SpreadOrExpression::Expression(e) => {
|
||||
match <&Expression<'a>>::from_ast(scope, e, expected_item.clone()) {
|
||||
Ok(expr) => expr.get_type().map(Type::partial),
|
||||
Err(_) => continue,
|
||||
}
|
||||
}
|
||||
_ => None,
|
||||
};
|
||||
|
||||
if expected_item.is_some() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut len = 0;
|
||||
|
||||
let output = ArrayInlineExpression {
|
||||
parent: Cell::new(None),
|
||||
span: Some(value.span.clone()),
|
||||
|
6
asg/tests/pass/array/implicit.leo
Normal file
6
asg/tests/pass/array/implicit.leo
Normal file
@ -0,0 +1,6 @@
|
||||
function main(){
|
||||
let a = [1u8, 2u8, 3u8, 4];
|
||||
let b = [1u8, 2u8, 3, 4u8];
|
||||
let c = [1u8, 2, 3u8, 4u8];
|
||||
let d = [1, 2u8, 3u8, 4u8];
|
||||
}
|
@ -104,6 +104,12 @@ fn test_slice_lower() {
|
||||
load_asg(program_string).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_implicit() {
|
||||
let program_string = include_str!("implicit.leo");
|
||||
load_asg(program_string).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_type_nested_value_nested_3x2() {
|
||||
let program_string = include_str!("type_nested_value_nested_3x2.leo");
|
||||
|
Loading…
Reference in New Issue
Block a user