mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-22 22:44:47 +03:00
Regen expectations
This commit is contained in:
parent
f81bb5bfcc
commit
36aa41fdc2
@ -321,9 +321,7 @@ impl ExpressionConsumer for StaticSingleAssigner<'_> {
|
||||
|
||||
/// Consumes and returns the locator expression without making any modifciations
|
||||
fn consume_locator(&mut self, input: LocatorExpression) -> Self::Output {
|
||||
// Construct and accumulate a new assignment statement for the locator expression.
|
||||
let (place, statement) = self.unique_simple_assign_statement(Expression::Locator(input));
|
||||
(Expression::Identifier(place), vec![statement])
|
||||
(Expression::Locator(input), Vec::new())
|
||||
}
|
||||
|
||||
/// Consumes a ternary expression, accumulating any statements that are generated.
|
||||
|
@ -1021,6 +1021,11 @@ impl<'a> TypeChecker<'a> {
|
||||
}
|
||||
// Check that the first argument is a mapping.
|
||||
if let Some(mapping_type) = self.assert_mapping_type(&arguments[0].0, arguments[0].1) {
|
||||
// Cannot use `contains` on external mappings.
|
||||
if mapping_type.program != self.program_name.unwrap() {
|
||||
self.handler
|
||||
.emit_err(TypeCheckerError::cannot_modify_external_mapping("contains", function_span));
|
||||
}
|
||||
// Check that the second argument matches the key type of the mapping.
|
||||
self.assert_type(&arguments[1].0, &mapping_type.key, arguments[1].1);
|
||||
// Return a boolean.
|
||||
|
@ -772,7 +772,7 @@ create_messages!(
|
||||
@formatted
|
||||
cannot_modify_external_mapping {
|
||||
args: (operation: impl Display),
|
||||
msg: format!("Cannot use operation `{operation}` to modify external mapping."),
|
||||
help: Some("The only valid operations on external mappings are get, get_or_use, and contains.".to_string()),
|
||||
msg: format!("Cannot use operation `{operation}` on external mapping."),
|
||||
help: Some("The only valid operations on external mappings are get, and get_or_use.".to_string()),
|
||||
}
|
||||
);
|
||||
|
@ -75,11 +75,17 @@ outputs:
|
||||
variant: "{\"id\":\"11\",\"name\":\"Mapping\",\"span\":\"{\\\"lo\\\":154,\\\"hi\\\":161}\"}"
|
||||
name: "{\"id\":\"12\",\"name\":\"set\",\"span\":\"{\\\"lo\\\":163,\\\"hi\\\":166}\"}"
|
||||
arguments:
|
||||
- Locator: "{\"id\":\"15\",\"name\":\"counter\",\"program\":\"hello\",\"span\":\"{\\\"lo\\\":167,\\\"hi\\\":185}\"}"
|
||||
- Identifier: "{\"id\":\"16\",\"name\":\"addr\",\"span\":\"{\\\"lo\\\":187,\\\"hi\\\":191}\"}"
|
||||
- Locator:
|
||||
program: "{\"name\":\"hello\",\"network\":\"\\\"{\\\\\\\"id\\\\\\\":\\\\\\\"15\\\\\\\",\\\\\\\"name\\\\\\\":\\\\\\\"aleo\\\\\\\",\\\\\\\"span\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"lo\\\\\\\\\\\\\\\":173,\\\\\\\\\\\\\\\"hi\\\\\\\\\\\\\\\":177}\\\\\\\"}\\\"\"}"
|
||||
name: counter
|
||||
span:
|
||||
lo: 167
|
||||
hi: 185
|
||||
id: 16
|
||||
- Identifier: "{\"id\":\"17\",\"name\":\"addr\",\"span\":\"{\\\"lo\\\":187,\\\"hi\\\":191}\"}"
|
||||
- Binary:
|
||||
left:
|
||||
Identifier: "{\"id\":\"17\",\"name\":\"current_value\",\"span\":\"{\\\"lo\\\":193,\\\"hi\\\":206}\"}"
|
||||
Identifier: "{\"id\":\"18\",\"name\":\"current_value\",\"span\":\"{\\\"lo\\\":193,\\\"hi\\\":206}\"}"
|
||||
right:
|
||||
Literal:
|
||||
Integer:
|
||||
@ -88,73 +94,91 @@ outputs:
|
||||
- span:
|
||||
lo: 209
|
||||
hi: 213
|
||||
- 18
|
||||
- 19
|
||||
op: Add
|
||||
span:
|
||||
lo: 193
|
||||
hi: 213
|
||||
id: 19
|
||||
id: 20
|
||||
span:
|
||||
lo: 154
|
||||
hi: 214
|
||||
id: 20
|
||||
id: 21
|
||||
span:
|
||||
lo: 154
|
||||
hi: 215
|
||||
id: 21
|
||||
id: 22
|
||||
- Expression:
|
||||
expression:
|
||||
Access:
|
||||
AssociatedFunction:
|
||||
variant: "{\"id\":\"22\",\"name\":\"Mapping\",\"span\":\"{\\\"lo\\\":224,\\\"hi\\\":231}\"}"
|
||||
name: "{\"id\":\"23\",\"name\":\"remove\",\"span\":\"{\\\"lo\\\":233,\\\"hi\\\":239}\"}"
|
||||
variant: "{\"id\":\"23\",\"name\":\"Mapping\",\"span\":\"{\\\"lo\\\":224,\\\"hi\\\":231}\"}"
|
||||
name: "{\"id\":\"24\",\"name\":\"remove\",\"span\":\"{\\\"lo\\\":233,\\\"hi\\\":239}\"}"
|
||||
arguments:
|
||||
- Locator: "{\"id\":\"26\",\"name\":\"foo\",\"program\":\"hello\",\"span\":\"{\\\"lo\\\":240,\\\"hi\\\":254}\"}"
|
||||
- Identifier: "{\"id\":\"27\",\"name\":\"addr\",\"span\":\"{\\\"lo\\\":256,\\\"hi\\\":260}\"}"
|
||||
- Locator:
|
||||
program: "{\"name\":\"hello\",\"network\":\"\\\"{\\\\\\\"id\\\\\\\":\\\\\\\"27\\\\\\\",\\\\\\\"name\\\\\\\":\\\\\\\"aleo\\\\\\\",\\\\\\\"span\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"lo\\\\\\\\\\\\\\\":246,\\\\\\\\\\\\\\\"hi\\\\\\\\\\\\\\\":250}\\\\\\\"}\\\"\"}"
|
||||
name: foo
|
||||
span:
|
||||
lo: 240
|
||||
hi: 254
|
||||
id: 28
|
||||
- Identifier: "{\"id\":\"29\",\"name\":\"addr\",\"span\":\"{\\\"lo\\\":256,\\\"hi\\\":260}\"}"
|
||||
span:
|
||||
lo: 224
|
||||
hi: 261
|
||||
id: 28
|
||||
id: 30
|
||||
span:
|
||||
lo: 224
|
||||
hi: 262
|
||||
id: 29
|
||||
id: 31
|
||||
- Definition:
|
||||
declaration_type: Let
|
||||
place:
|
||||
Identifier: "{\"id\":\"30\",\"name\":\"a\",\"span\":\"{\\\"lo\\\":275,\\\"hi\\\":276}\"}"
|
||||
Identifier: "{\"id\":\"32\",\"name\":\"a\",\"span\":\"{\\\"lo\\\":275,\\\"hi\\\":276}\"}"
|
||||
type_:
|
||||
Integer: U32
|
||||
value:
|
||||
Access:
|
||||
AssociatedFunction:
|
||||
variant: "{\"id\":\"31\",\"name\":\"Mapping\",\"span\":\"{\\\"lo\\\":283,\\\"hi\\\":290}\"}"
|
||||
name: "{\"id\":\"32\",\"name\":\"get\",\"span\":\"{\\\"lo\\\":292,\\\"hi\\\":295}\"}"
|
||||
variant: "{\"id\":\"33\",\"name\":\"Mapping\",\"span\":\"{\\\"lo\\\":283,\\\"hi\\\":290}\"}"
|
||||
name: "{\"id\":\"34\",\"name\":\"get\",\"span\":\"{\\\"lo\\\":292,\\\"hi\\\":295}\"}"
|
||||
arguments:
|
||||
- Locator: "{\"id\":\"35\",\"name\":\"foo\",\"program\":\"hello\",\"span\":\"{\\\"lo\\\":296,\\\"hi\\\":310}\"}"
|
||||
- Identifier: "{\"id\":\"36\",\"name\":\"addr\",\"span\":\"{\\\"lo\\\":312,\\\"hi\\\":316}\"}"
|
||||
- Locator:
|
||||
program: "{\"name\":\"hello\",\"network\":\"\\\"{\\\\\\\"id\\\\\\\":\\\\\\\"37\\\\\\\",\\\\\\\"name\\\\\\\":\\\\\\\"aleo\\\\\\\",\\\\\\\"span\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"lo\\\\\\\\\\\\\\\":302,\\\\\\\\\\\\\\\"hi\\\\\\\\\\\\\\\":306}\\\\\\\"}\\\"\"}"
|
||||
name: foo
|
||||
span:
|
||||
lo: 296
|
||||
hi: 310
|
||||
id: 38
|
||||
- Identifier: "{\"id\":\"39\",\"name\":\"addr\",\"span\":\"{\\\"lo\\\":312,\\\"hi\\\":316}\"}"
|
||||
span:
|
||||
lo: 283
|
||||
hi: 317
|
||||
id: 37
|
||||
id: 40
|
||||
span:
|
||||
lo: 271
|
||||
hi: 317
|
||||
id: 38
|
||||
id: 41
|
||||
- Definition:
|
||||
declaration_type: Let
|
||||
place:
|
||||
Identifier: "{\"id\":\"39\",\"name\":\"b\",\"span\":\"{\\\"lo\\\":331,\\\"hi\\\":332}\"}"
|
||||
Identifier: "{\"id\":\"42\",\"name\":\"b\",\"span\":\"{\\\"lo\\\":331,\\\"hi\\\":332}\"}"
|
||||
type_:
|
||||
Integer: U32
|
||||
value:
|
||||
Access:
|
||||
AssociatedFunction:
|
||||
variant: "{\"id\":\"40\",\"name\":\"Mapping\",\"span\":\"{\\\"lo\\\":339,\\\"hi\\\":346}\"}"
|
||||
name: "{\"id\":\"41\",\"name\":\"get_or_use\",\"span\":\"{\\\"lo\\\":348,\\\"hi\\\":358}\"}"
|
||||
variant: "{\"id\":\"43\",\"name\":\"Mapping\",\"span\":\"{\\\"lo\\\":339,\\\"hi\\\":346}\"}"
|
||||
name: "{\"id\":\"44\",\"name\":\"get_or_use\",\"span\":\"{\\\"lo\\\":348,\\\"hi\\\":358}\"}"
|
||||
arguments:
|
||||
- Locator: "{\"id\":\"44\",\"name\":\"foo\",\"program\":\"hello\",\"span\":\"{\\\"lo\\\":359,\\\"hi\\\":373}\"}"
|
||||
- Identifier: "{\"id\":\"45\",\"name\":\"addr\",\"span\":\"{\\\"lo\\\":375,\\\"hi\\\":379}\"}"
|
||||
- Locator:
|
||||
program: "{\"name\":\"hello\",\"network\":\"\\\"{\\\\\\\"id\\\\\\\":\\\\\\\"47\\\\\\\",\\\\\\\"name\\\\\\\":\\\\\\\"aleo\\\\\\\",\\\\\\\"span\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"lo\\\\\\\\\\\\\\\":365,\\\\\\\\\\\\\\\"hi\\\\\\\\\\\\\\\":369}\\\\\\\"}\\\"\"}"
|
||||
name: foo
|
||||
span:
|
||||
lo: 359
|
||||
hi: 373
|
||||
id: 48
|
||||
- Identifier: "{\"id\":\"49\",\"name\":\"addr\",\"span\":\"{\\\"lo\\\":375,\\\"hi\\\":379}\"}"
|
||||
- Literal:
|
||||
Integer:
|
||||
- U64
|
||||
@ -162,49 +186,55 @@ outputs:
|
||||
- span:
|
||||
lo: 381
|
||||
hi: 385
|
||||
- 46
|
||||
- 50
|
||||
span:
|
||||
lo: 339
|
||||
hi: 386
|
||||
id: 47
|
||||
id: 51
|
||||
span:
|
||||
lo: 327
|
||||
hi: 386
|
||||
id: 48
|
||||
id: 52
|
||||
- Definition:
|
||||
declaration_type: Let
|
||||
place:
|
||||
Identifier: "{\"id\":\"49\",\"name\":\"c\",\"span\":\"{\\\"lo\\\":400,\\\"hi\\\":401}\"}"
|
||||
Identifier: "{\"id\":\"53\",\"name\":\"c\",\"span\":\"{\\\"lo\\\":400,\\\"hi\\\":401}\"}"
|
||||
type_:
|
||||
Integer: U32
|
||||
value:
|
||||
Access:
|
||||
AssociatedFunction:
|
||||
variant: "{\"id\":\"50\",\"name\":\"Mapping\",\"span\":\"{\\\"lo\\\":408,\\\"hi\\\":415}\"}"
|
||||
name: "{\"id\":\"51\",\"name\":\"contains\",\"span\":\"{\\\"lo\\\":417,\\\"hi\\\":425}\"}"
|
||||
variant: "{\"id\":\"54\",\"name\":\"Mapping\",\"span\":\"{\\\"lo\\\":408,\\\"hi\\\":415}\"}"
|
||||
name: "{\"id\":\"55\",\"name\":\"contains\",\"span\":\"{\\\"lo\\\":417,\\\"hi\\\":425}\"}"
|
||||
arguments:
|
||||
- Locator: "{\"id\":\"54\",\"name\":\"foo\",\"program\":\"hello\",\"span\":\"{\\\"lo\\\":426,\\\"hi\\\":440}\"}"
|
||||
- Identifier: "{\"id\":\"55\",\"name\":\"addr\",\"span\":\"{\\\"lo\\\":442,\\\"hi\\\":446}\"}"
|
||||
- Locator:
|
||||
program: "{\"name\":\"hello\",\"network\":\"\\\"{\\\\\\\"id\\\\\\\":\\\\\\\"58\\\\\\\",\\\\\\\"name\\\\\\\":\\\\\\\"aleo\\\\\\\",\\\\\\\"span\\\\\\\":\\\\\\\"{\\\\\\\\\\\\\\\"lo\\\\\\\\\\\\\\\":432,\\\\\\\\\\\\\\\"hi\\\\\\\\\\\\\\\":436}\\\\\\\"}\\\"\"}"
|
||||
name: foo
|
||||
span:
|
||||
lo: 426
|
||||
hi: 440
|
||||
id: 59
|
||||
- Identifier: "{\"id\":\"60\",\"name\":\"addr\",\"span\":\"{\\\"lo\\\":442,\\\"hi\\\":446}\"}"
|
||||
span:
|
||||
lo: 408
|
||||
hi: 447
|
||||
id: 56
|
||||
id: 61
|
||||
span:
|
||||
lo: 396
|
||||
hi: 447
|
||||
id: 57
|
||||
id: 62
|
||||
span:
|
||||
lo: 144
|
||||
hi: 454
|
||||
id: 58
|
||||
id: 63
|
||||
span:
|
||||
lo: 128
|
||||
hi: 454
|
||||
id: 59
|
||||
id: 64
|
||||
span:
|
||||
lo: 44
|
||||
hi: 123
|
||||
id: 60
|
||||
id: 65
|
||||
span:
|
||||
lo: 20
|
||||
hi: 456
|
||||
|
Loading…
Reference in New Issue
Block a user