mirror of
https://github.com/AleoHQ/leo.git
synced 2025-01-03 07:16:50 +03:00
Merge pull request #809 from AleoHQ/bug/807-compound-operator-access-fix
Bug-807 Compound Access fix.
This commit is contained in:
commit
848872de15
@ -470,7 +470,35 @@ impl ReconstructingReducer for Canonicalizer {
|
||||
) -> Result<AssignStatement, CanonicalizeError> {
|
||||
match value {
|
||||
Expression::Value(value_expr) if assign.operation != AssignOperation::Assign => {
|
||||
let left = Box::new(Expression::Identifier(assignee.identifier.clone()));
|
||||
let mut left = Box::new(Expression::Identifier(assignee.identifier.clone()));
|
||||
|
||||
for access in assignee.accesses.iter().rev() {
|
||||
match self.canonicalize_assignee_access(&access) {
|
||||
AssigneeAccess::ArrayIndex(index) => {
|
||||
left = Box::new(Expression::ArrayAccess(ArrayAccessExpression {
|
||||
array: left,
|
||||
index: Box::new(index),
|
||||
span: assign.span.clone(),
|
||||
}));
|
||||
}
|
||||
AssigneeAccess::Tuple(positive_number, _) => {
|
||||
left = Box::new(Expression::TupleAccess(TupleAccessExpression {
|
||||
tuple: left,
|
||||
index: positive_number,
|
||||
span: assign.span.clone(),
|
||||
}));
|
||||
}
|
||||
AssigneeAccess::Member(identifier) => {
|
||||
left = Box::new(Expression::CircuitMemberAccess(CircuitMemberAccessExpression {
|
||||
circuit: left,
|
||||
name: identifier,
|
||||
span: assign.span.clone(),
|
||||
}));
|
||||
}
|
||||
_ => unimplemented!(), // No reason for someone to compute ArrayRanges.
|
||||
}
|
||||
}
|
||||
|
||||
let right = Box::new(Expression::Value(value_expr));
|
||||
|
||||
let op = match assign.operation {
|
||||
|
@ -2,11 +2,25 @@
|
||||
"name": "",
|
||||
"expected_input": [],
|
||||
"imports": [],
|
||||
"circuits": {},
|
||||
"circuits": {
|
||||
"{\"name\":\"Foo\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":9,\\\"col_stop\\\":12,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"circuit Foo {\\\"}\"}": {
|
||||
"circuit_name": "{\"name\":\"Foo\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":9,\\\"col_stop\\\":12,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"circuit Foo {\\\"}\"}",
|
||||
"members": [
|
||||
{
|
||||
"CircuitVariable": [
|
||||
"{\"name\":\"f\",\"span\":\"{\\\"line_start\\\":2,\\\"line_stop\\\":2,\\\"col_start\\\":3,\\\"col_stop\\\":4,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" f: u8,\\\"}\"}",
|
||||
{
|
||||
"IntegerType": "U8"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"functions": {
|
||||
"{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function main() {\\\"}\"}": {
|
||||
"{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":4,\\\"line_stop\\\":4,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function main() {\\\"}\"}": {
|
||||
"annotations": [],
|
||||
"identifier": "{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function main() {\\\"}\"}",
|
||||
"identifier": "{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":4,\\\"line_stop\\\":4,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function main() {\\\"}\"}",
|
||||
"input": [],
|
||||
"output": {
|
||||
"Tuple": []
|
||||
@ -19,10 +33,10 @@
|
||||
"variable_names": [
|
||||
{
|
||||
"mutable": true,
|
||||
"identifier": "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":2,\\\"line_stop\\\":2,\\\"col_start\\\":7,\\\"col_stop\\\":8,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" let x = 10u32;\\\"}\"}",
|
||||
"identifier": "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":5,\\\"line_stop\\\":5,\\\"col_start\\\":7,\\\"col_stop\\\":8,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" let x = 10u32;\\\"}\"}",
|
||||
"span": {
|
||||
"line_start": 2,
|
||||
"line_stop": 2,
|
||||
"line_start": 5,
|
||||
"line_stop": 5,
|
||||
"col_start": 7,
|
||||
"col_stop": 8,
|
||||
"path": "",
|
||||
@ -37,8 +51,8 @@
|
||||
"U32",
|
||||
"10",
|
||||
{
|
||||
"line_start": 2,
|
||||
"line_stop": 2,
|
||||
"line_start": 5,
|
||||
"line_stop": 5,
|
||||
"col_start": 11,
|
||||
"col_stop": 16,
|
||||
"path": "",
|
||||
@ -48,8 +62,8 @@
|
||||
}
|
||||
},
|
||||
"span": {
|
||||
"line_start": 2,
|
||||
"line_stop": 2,
|
||||
"line_start": 5,
|
||||
"line_stop": 5,
|
||||
"col_start": 3,
|
||||
"col_stop": 16,
|
||||
"path": "",
|
||||
@ -61,11 +75,11 @@
|
||||
"Assign": {
|
||||
"operation": "Assign",
|
||||
"assignee": {
|
||||
"identifier": "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":3,\\\"col_stop\\\":4,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" x += 20;\\\"}\"}",
|
||||
"identifier": "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":6,\\\"line_stop\\\":6,\\\"col_start\\\":3,\\\"col_stop\\\":4,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" x += 20;\\\"}\"}",
|
||||
"accesses": [],
|
||||
"span": {
|
||||
"line_start": 3,
|
||||
"line_stop": 3,
|
||||
"line_start": 6,
|
||||
"line_stop": 6,
|
||||
"col_start": 3,
|
||||
"col_stop": 4,
|
||||
"path": "",
|
||||
@ -75,15 +89,15 @@
|
||||
"value": {
|
||||
"Binary": {
|
||||
"left": {
|
||||
"Identifier": "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":3,\\\"col_stop\\\":4,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" x += 20;\\\"}\"}"
|
||||
"Identifier": "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":6,\\\"line_stop\\\":6,\\\"col_start\\\":3,\\\"col_stop\\\":4,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" x += 20;\\\"}\"}"
|
||||
},
|
||||
"right": {
|
||||
"Value": {
|
||||
"Implicit": [
|
||||
"20",
|
||||
{
|
||||
"line_start": 3,
|
||||
"line_stop": 3,
|
||||
"line_start": 6,
|
||||
"line_stop": 6,
|
||||
"col_start": 8,
|
||||
"col_stop": 10,
|
||||
"path": "",
|
||||
@ -94,8 +108,8 @@
|
||||
},
|
||||
"op": "Add",
|
||||
"span": {
|
||||
"line_start": 3,
|
||||
"line_stop": 3,
|
||||
"line_start": 6,
|
||||
"line_stop": 6,
|
||||
"col_start": 3,
|
||||
"col_stop": 10,
|
||||
"path": "",
|
||||
@ -104,33 +118,750 @@
|
||||
}
|
||||
},
|
||||
"span": {
|
||||
"line_start": 3,
|
||||
"line_stop": 3,
|
||||
"line_start": 6,
|
||||
"line_stop": 6,
|
||||
"col_start": 3,
|
||||
"col_stop": 10,
|
||||
"path": "",
|
||||
"content": " x += 20;"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"Console": {
|
||||
"function": {
|
||||
"Assert": {
|
||||
"Binary": {
|
||||
"left": {
|
||||
"Identifier": "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":7,\\\"line_stop\\\":7,\\\"col_start\\\":18,\\\"col_stop\\\":19,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" console.assert(x == 30u32);\\\"}\"}"
|
||||
},
|
||||
"right": {
|
||||
"Value": {
|
||||
"Integer": [
|
||||
"U32",
|
||||
"30",
|
||||
{
|
||||
"line_start": 7,
|
||||
"line_stop": 7,
|
||||
"col_start": 23,
|
||||
"col_stop": 28,
|
||||
"path": "",
|
||||
"content": " console.assert(x == 30u32);"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"op": "Eq",
|
||||
"span": {
|
||||
"line_start": 7,
|
||||
"line_stop": 7,
|
||||
"col_start": 18,
|
||||
"col_stop": 28,
|
||||
"path": "",
|
||||
"content": " console.assert(x == 30u32);"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"span": {
|
||||
"line_start": 7,
|
||||
"line_stop": 7,
|
||||
"col_start": 3,
|
||||
"col_stop": 28,
|
||||
"path": "",
|
||||
"content": " console.assert(x == 30u32);"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"Definition": {
|
||||
"declaration_type": "Let",
|
||||
"variable_names": [
|
||||
{
|
||||
"mutable": true,
|
||||
"identifier": "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":9,\\\"line_stop\\\":9,\\\"col_start\\\":7,\\\"col_stop\\\":8,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" let y = [1u8, 2u8];\\\"}\"}",
|
||||
"span": {
|
||||
"line_start": 9,
|
||||
"line_stop": 9,
|
||||
"col_start": 7,
|
||||
"col_stop": 8,
|
||||
"path": "",
|
||||
"content": " let y = [1u8, 2u8];"
|
||||
}
|
||||
}
|
||||
],
|
||||
"type_": null,
|
||||
"value": {
|
||||
"ArrayInline": {
|
||||
"elements": [
|
||||
{
|
||||
"Expression": {
|
||||
"Value": {
|
||||
"Integer": [
|
||||
"U8",
|
||||
"1",
|
||||
{
|
||||
"line_start": 9,
|
||||
"line_stop": 9,
|
||||
"col_start": 12,
|
||||
"col_stop": 15,
|
||||
"path": "",
|
||||
"content": " let y = [1u8, 2u8];"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"Expression": {
|
||||
"Value": {
|
||||
"Integer": [
|
||||
"U8",
|
||||
"2",
|
||||
{
|
||||
"line_start": 9,
|
||||
"line_stop": 9,
|
||||
"col_start": 17,
|
||||
"col_stop": 20,
|
||||
"path": "",
|
||||
"content": " let y = [1u8, 2u8];"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"span": {
|
||||
"line_start": 9,
|
||||
"line_stop": 9,
|
||||
"col_start": 11,
|
||||
"col_stop": 21,
|
||||
"path": "",
|
||||
"content": " let y = [1u8, 2u8];"
|
||||
}
|
||||
}
|
||||
},
|
||||
"span": {
|
||||
"line_start": 9,
|
||||
"line_stop": 9,
|
||||
"col_start": 3,
|
||||
"col_stop": 21,
|
||||
"path": "",
|
||||
"content": " let y = [1u8, 2u8];"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"Assign": {
|
||||
"operation": "Assign",
|
||||
"assignee": {
|
||||
"identifier": "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":10,\\\"line_stop\\\":10,\\\"col_start\\\":3,\\\"col_stop\\\":4,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" y[0] += 3u8;\\\"}\"}",
|
||||
"accesses": [
|
||||
{
|
||||
"ArrayIndex": {
|
||||
"Value": {
|
||||
"Implicit": [
|
||||
"0",
|
||||
{
|
||||
"line_start": 10,
|
||||
"line_stop": 10,
|
||||
"col_start": 5,
|
||||
"col_stop": 6,
|
||||
"path": "",
|
||||
"content": " y[0] += 3u8;"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"span": {
|
||||
"line_start": 10,
|
||||
"line_stop": 10,
|
||||
"col_start": 3,
|
||||
"col_stop": 7,
|
||||
"path": "",
|
||||
"content": " y[0] += 3u8;"
|
||||
}
|
||||
},
|
||||
"value": {
|
||||
"Binary": {
|
||||
"left": {
|
||||
"ArrayAccess": {
|
||||
"array": {
|
||||
"Identifier": "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":10,\\\"line_stop\\\":10,\\\"col_start\\\":3,\\\"col_stop\\\":4,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" y[0] += 3u8;\\\"}\"}"
|
||||
},
|
||||
"index": {
|
||||
"Value": {
|
||||
"Implicit": [
|
||||
"0",
|
||||
{
|
||||
"line_start": 10,
|
||||
"line_stop": 10,
|
||||
"col_start": 5,
|
||||
"col_stop": 6,
|
||||
"path": "",
|
||||
"content": " y[0] += 3u8;"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"span": {
|
||||
"line_start": 10,
|
||||
"line_stop": 10,
|
||||
"col_start": 3,
|
||||
"col_stop": 14,
|
||||
"path": "",
|
||||
"content": " y[0] += 3u8;"
|
||||
}
|
||||
}
|
||||
},
|
||||
"right": {
|
||||
"Value": {
|
||||
"Integer": [
|
||||
"U8",
|
||||
"3",
|
||||
{
|
||||
"line_start": 10,
|
||||
"line_stop": 10,
|
||||
"col_start": 11,
|
||||
"col_stop": 14,
|
||||
"path": "",
|
||||
"content": " y[0] += 3u8;"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"op": "Add",
|
||||
"span": {
|
||||
"line_start": 10,
|
||||
"line_stop": 10,
|
||||
"col_start": 3,
|
||||
"col_stop": 14,
|
||||
"path": "",
|
||||
"content": " y[0] += 3u8;"
|
||||
}
|
||||
}
|
||||
},
|
||||
"span": {
|
||||
"line_start": 10,
|
||||
"line_stop": 10,
|
||||
"col_start": 3,
|
||||
"col_stop": 14,
|
||||
"path": "",
|
||||
"content": " y[0] += 3u8;"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"Console": {
|
||||
"function": {
|
||||
"Assert": {
|
||||
"Binary": {
|
||||
"left": {
|
||||
"ArrayAccess": {
|
||||
"array": {
|
||||
"Identifier": "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":11,\\\"line_stop\\\":11,\\\"col_start\\\":18,\\\"col_stop\\\":19,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" console.assert(y[0] == 4u8);\\\"}\"}"
|
||||
},
|
||||
"index": {
|
||||
"Value": {
|
||||
"Implicit": [
|
||||
"0",
|
||||
{
|
||||
"line_start": 11,
|
||||
"line_stop": 11,
|
||||
"col_start": 20,
|
||||
"col_stop": 21,
|
||||
"path": "",
|
||||
"content": " console.assert(y[0] == 4u8);"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"span": {
|
||||
"line_start": 11,
|
||||
"line_stop": 11,
|
||||
"col_start": 18,
|
||||
"col_stop": 22,
|
||||
"path": "",
|
||||
"content": " console.assert(y[0] == 4u8);"
|
||||
}
|
||||
}
|
||||
},
|
||||
"right": {
|
||||
"Value": {
|
||||
"Integer": [
|
||||
"U8",
|
||||
"4",
|
||||
{
|
||||
"line_start": 11,
|
||||
"line_stop": 11,
|
||||
"col_start": 26,
|
||||
"col_stop": 29,
|
||||
"path": "",
|
||||
"content": " console.assert(y[0] == 4u8);"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"op": "Eq",
|
||||
"span": {
|
||||
"line_start": 11,
|
||||
"line_stop": 11,
|
||||
"col_start": 18,
|
||||
"col_stop": 29,
|
||||
"path": "",
|
||||
"content": " console.assert(y[0] == 4u8);"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"span": {
|
||||
"line_start": 11,
|
||||
"line_stop": 11,
|
||||
"col_start": 3,
|
||||
"col_stop": 29,
|
||||
"path": "",
|
||||
"content": " console.assert(y[0] == 4u8);"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"Definition": {
|
||||
"declaration_type": "Let",
|
||||
"variable_names": [
|
||||
{
|
||||
"mutable": true,
|
||||
"identifier": "{\"name\":\"z\",\"span\":\"{\\\"line_start\\\":13,\\\"line_stop\\\":13,\\\"col_start\\\":7,\\\"col_stop\\\":8,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" let z = (1u8, 2u8);\\\"}\"}",
|
||||
"span": {
|
||||
"line_start": 13,
|
||||
"line_stop": 13,
|
||||
"col_start": 7,
|
||||
"col_stop": 8,
|
||||
"path": "",
|
||||
"content": " let z = (1u8, 2u8);"
|
||||
}
|
||||
}
|
||||
],
|
||||
"type_": null,
|
||||
"value": {
|
||||
"TupleInit": {
|
||||
"elements": [
|
||||
{
|
||||
"Value": {
|
||||
"Integer": [
|
||||
"U8",
|
||||
"1",
|
||||
{
|
||||
"line_start": 13,
|
||||
"line_stop": 13,
|
||||
"col_start": 12,
|
||||
"col_stop": 15,
|
||||
"path": "",
|
||||
"content": " let z = (1u8, 2u8);"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"Value": {
|
||||
"Integer": [
|
||||
"U8",
|
||||
"2",
|
||||
{
|
||||
"line_start": 13,
|
||||
"line_stop": 13,
|
||||
"col_start": 17,
|
||||
"col_stop": 20,
|
||||
"path": "",
|
||||
"content": " let z = (1u8, 2u8);"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"span": {
|
||||
"line_start": 13,
|
||||
"line_stop": 13,
|
||||
"col_start": 11,
|
||||
"col_stop": 21,
|
||||
"path": "",
|
||||
"content": " let z = (1u8, 2u8);"
|
||||
}
|
||||
}
|
||||
},
|
||||
"span": {
|
||||
"line_start": 13,
|
||||
"line_stop": 13,
|
||||
"col_start": 3,
|
||||
"col_stop": 21,
|
||||
"path": "",
|
||||
"content": " let z = (1u8, 2u8);"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"Assign": {
|
||||
"operation": "Assign",
|
||||
"assignee": {
|
||||
"identifier": "{\"name\":\"z\",\"span\":\"{\\\"line_start\\\":14,\\\"line_stop\\\":14,\\\"col_start\\\":3,\\\"col_stop\\\":4,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" z.1 += 3u8;\\\"}\"}",
|
||||
"accesses": [
|
||||
{
|
||||
"Tuple": [
|
||||
{
|
||||
"value": "1"
|
||||
},
|
||||
{
|
||||
"line_start": 14,
|
||||
"line_stop": 14,
|
||||
"col_start": 3,
|
||||
"col_stop": 6,
|
||||
"path": "",
|
||||
"content": " z.1 += 3u8;"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"span": {
|
||||
"line_start": 14,
|
||||
"line_stop": 14,
|
||||
"col_start": 3,
|
||||
"col_stop": 6,
|
||||
"path": "",
|
||||
"content": " z.1 += 3u8;"
|
||||
}
|
||||
},
|
||||
"value": {
|
||||
"Binary": {
|
||||
"left": {
|
||||
"TupleAccess": {
|
||||
"tuple": {
|
||||
"Identifier": "{\"name\":\"z\",\"span\":\"{\\\"line_start\\\":14,\\\"line_stop\\\":14,\\\"col_start\\\":3,\\\"col_stop\\\":4,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" z.1 += 3u8;\\\"}\"}"
|
||||
},
|
||||
"index": {
|
||||
"value": "1"
|
||||
},
|
||||
"span": {
|
||||
"line_start": 14,
|
||||
"line_stop": 14,
|
||||
"col_start": 3,
|
||||
"col_stop": 13,
|
||||
"path": "",
|
||||
"content": " z.1 += 3u8;"
|
||||
}
|
||||
}
|
||||
},
|
||||
"right": {
|
||||
"Value": {
|
||||
"Integer": [
|
||||
"U8",
|
||||
"3",
|
||||
{
|
||||
"line_start": 14,
|
||||
"line_stop": 14,
|
||||
"col_start": 10,
|
||||
"col_stop": 13,
|
||||
"path": "",
|
||||
"content": " z.1 += 3u8;"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"op": "Add",
|
||||
"span": {
|
||||
"line_start": 14,
|
||||
"line_stop": 14,
|
||||
"col_start": 3,
|
||||
"col_stop": 13,
|
||||
"path": "",
|
||||
"content": " z.1 += 3u8;"
|
||||
}
|
||||
}
|
||||
},
|
||||
"span": {
|
||||
"line_start": 14,
|
||||
"line_stop": 14,
|
||||
"col_start": 3,
|
||||
"col_stop": 13,
|
||||
"path": "",
|
||||
"content": " z.1 += 3u8;"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"Console": {
|
||||
"function": {
|
||||
"Assert": {
|
||||
"Binary": {
|
||||
"left": {
|
||||
"TupleAccess": {
|
||||
"tuple": {
|
||||
"Identifier": "{\"name\":\"z\",\"span\":\"{\\\"line_start\\\":15,\\\"line_stop\\\":15,\\\"col_start\\\":18,\\\"col_stop\\\":19,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" console.assert(z.1 == 5u8);\\\"}\"}"
|
||||
},
|
||||
"index": {
|
||||
"value": "1"
|
||||
},
|
||||
"span": {
|
||||
"line_start": 15,
|
||||
"line_stop": 15,
|
||||
"col_start": 18,
|
||||
"col_stop": 21,
|
||||
"path": "",
|
||||
"content": " console.assert(z.1 == 5u8);"
|
||||
}
|
||||
}
|
||||
},
|
||||
"right": {
|
||||
"Value": {
|
||||
"Integer": [
|
||||
"U8",
|
||||
"5",
|
||||
{
|
||||
"line_start": 15,
|
||||
"line_stop": 15,
|
||||
"col_start": 25,
|
||||
"col_stop": 28,
|
||||
"path": "",
|
||||
"content": " console.assert(z.1 == 5u8);"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"op": "Eq",
|
||||
"span": {
|
||||
"line_start": 15,
|
||||
"line_stop": 15,
|
||||
"col_start": 18,
|
||||
"col_stop": 28,
|
||||
"path": "",
|
||||
"content": " console.assert(z.1 == 5u8);"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"span": {
|
||||
"line_start": 15,
|
||||
"line_stop": 15,
|
||||
"col_start": 3,
|
||||
"col_stop": 28,
|
||||
"path": "",
|
||||
"content": " console.assert(z.1 == 5u8);"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"Definition": {
|
||||
"declaration_type": "Let",
|
||||
"variable_names": [
|
||||
{
|
||||
"mutable": true,
|
||||
"identifier": "{\"name\":\"foo\",\"span\":\"{\\\"line_start\\\":17,\\\"line_stop\\\":17,\\\"col_start\\\":7,\\\"col_stop\\\":10,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" let foo = Foo { f: 6u8 };\\\"}\"}",
|
||||
"span": {
|
||||
"line_start": 17,
|
||||
"line_stop": 17,
|
||||
"col_start": 7,
|
||||
"col_stop": 10,
|
||||
"path": "",
|
||||
"content": " let foo = Foo { f: 6u8 };"
|
||||
}
|
||||
}
|
||||
],
|
||||
"type_": null,
|
||||
"value": {
|
||||
"CircuitInit": {
|
||||
"name": "{\"name\":\"Foo\",\"span\":\"{\\\"line_start\\\":17,\\\"line_stop\\\":17,\\\"col_start\\\":13,\\\"col_stop\\\":16,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" let foo = Foo { f: 6u8 };\\\"}\"}",
|
||||
"members": [
|
||||
{
|
||||
"identifier": "{\"name\":\"f\",\"span\":\"{\\\"line_start\\\":17,\\\"line_stop\\\":17,\\\"col_start\\\":19,\\\"col_stop\\\":20,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" let foo = Foo { f: 6u8 };\\\"}\"}",
|
||||
"expression": {
|
||||
"Value": {
|
||||
"Integer": [
|
||||
"U8",
|
||||
"6",
|
||||
{
|
||||
"line_start": 17,
|
||||
"line_stop": 17,
|
||||
"col_start": 22,
|
||||
"col_stop": 25,
|
||||
"path": "",
|
||||
"content": " let foo = Foo { f: 6u8 };"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"span": {
|
||||
"line_start": 17,
|
||||
"line_stop": 17,
|
||||
"col_start": 13,
|
||||
"col_stop": 27,
|
||||
"path": "",
|
||||
"content": " let foo = Foo { f: 6u8 };"
|
||||
}
|
||||
}
|
||||
},
|
||||
"span": {
|
||||
"line_start": 17,
|
||||
"line_stop": 17,
|
||||
"col_start": 3,
|
||||
"col_stop": 27,
|
||||
"path": "",
|
||||
"content": " let foo = Foo { f: 6u8 };"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"Assign": {
|
||||
"operation": "Assign",
|
||||
"assignee": {
|
||||
"identifier": "{\"name\":\"foo\",\"span\":\"{\\\"line_start\\\":18,\\\"line_stop\\\":18,\\\"col_start\\\":3,\\\"col_stop\\\":6,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" foo.f += 2u8;\\\"}\"}",
|
||||
"accesses": [
|
||||
{
|
||||
"Member": "{\"name\":\"f\",\"span\":\"{\\\"line_start\\\":18,\\\"line_stop\\\":18,\\\"col_start\\\":7,\\\"col_stop\\\":8,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" foo.f += 2u8;\\\"}\"}"
|
||||
}
|
||||
],
|
||||
"span": {
|
||||
"line_start": 18,
|
||||
"line_stop": 18,
|
||||
"col_start": 3,
|
||||
"col_stop": 8,
|
||||
"path": "",
|
||||
"content": " foo.f += 2u8;"
|
||||
}
|
||||
},
|
||||
"value": {
|
||||
"Binary": {
|
||||
"left": {
|
||||
"CircuitMemberAccess": {
|
||||
"circuit": {
|
||||
"Identifier": "{\"name\":\"foo\",\"span\":\"{\\\"line_start\\\":18,\\\"line_stop\\\":18,\\\"col_start\\\":3,\\\"col_stop\\\":6,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" foo.f += 2u8;\\\"}\"}"
|
||||
},
|
||||
"name": "{\"name\":\"f\",\"span\":\"{\\\"line_start\\\":18,\\\"line_stop\\\":18,\\\"col_start\\\":7,\\\"col_stop\\\":8,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" foo.f += 2u8;\\\"}\"}",
|
||||
"span": {
|
||||
"line_start": 18,
|
||||
"line_stop": 18,
|
||||
"col_start": 3,
|
||||
"col_stop": 15,
|
||||
"path": "",
|
||||
"content": " foo.f += 2u8;"
|
||||
}
|
||||
}
|
||||
},
|
||||
"right": {
|
||||
"Value": {
|
||||
"Integer": [
|
||||
"U8",
|
||||
"2",
|
||||
{
|
||||
"line_start": 18,
|
||||
"line_stop": 18,
|
||||
"col_start": 12,
|
||||
"col_stop": 15,
|
||||
"path": "",
|
||||
"content": " foo.f += 2u8;"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"op": "Add",
|
||||
"span": {
|
||||
"line_start": 18,
|
||||
"line_stop": 18,
|
||||
"col_start": 3,
|
||||
"col_stop": 15,
|
||||
"path": "",
|
||||
"content": " foo.f += 2u8;"
|
||||
}
|
||||
}
|
||||
},
|
||||
"span": {
|
||||
"line_start": 18,
|
||||
"line_stop": 18,
|
||||
"col_start": 3,
|
||||
"col_stop": 15,
|
||||
"path": "",
|
||||
"content": " foo.f += 2u8;"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"Console": {
|
||||
"function": {
|
||||
"Assert": {
|
||||
"Binary": {
|
||||
"left": {
|
||||
"CircuitMemberAccess": {
|
||||
"circuit": {
|
||||
"Identifier": "{\"name\":\"foo\",\"span\":\"{\\\"line_start\\\":19,\\\"line_stop\\\":19,\\\"col_start\\\":18,\\\"col_stop\\\":21,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" console.assert(foo.f == 8u8);\\\"}\"}"
|
||||
},
|
||||
"name": "{\"name\":\"f\",\"span\":\"{\\\"line_start\\\":19,\\\"line_stop\\\":19,\\\"col_start\\\":22,\\\"col_stop\\\":23,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" console.assert(foo.f == 8u8);\\\"}\"}",
|
||||
"span": {
|
||||
"line_start": 19,
|
||||
"line_stop": 19,
|
||||
"col_start": 18,
|
||||
"col_stop": 23,
|
||||
"path": "",
|
||||
"content": " console.assert(foo.f == 8u8);"
|
||||
}
|
||||
}
|
||||
},
|
||||
"right": {
|
||||
"Value": {
|
||||
"Integer": [
|
||||
"U8",
|
||||
"8",
|
||||
{
|
||||
"line_start": 19,
|
||||
"line_stop": 19,
|
||||
"col_start": 27,
|
||||
"col_stop": 30,
|
||||
"path": "",
|
||||
"content": " console.assert(foo.f == 8u8);"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"op": "Eq",
|
||||
"span": {
|
||||
"line_start": 19,
|
||||
"line_stop": 19,
|
||||
"col_start": 18,
|
||||
"col_stop": 30,
|
||||
"path": "",
|
||||
"content": " console.assert(foo.f == 8u8);"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"span": {
|
||||
"line_start": 19,
|
||||
"line_stop": 19,
|
||||
"col_start": 3,
|
||||
"col_stop": 30,
|
||||
"path": "",
|
||||
"content": " console.assert(foo.f == 8u8);"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"span": {
|
||||
"line_start": 1,
|
||||
"line_stop": 4,
|
||||
"line_start": 4,
|
||||
"line_stop": 20,
|
||||
"col_start": 17,
|
||||
"col_stop": 2,
|
||||
"path": "",
|
||||
"content": "function main() {\n...\n}"
|
||||
"content": "function main() {\n...\n} "
|
||||
}
|
||||
},
|
||||
"span": {
|
||||
"line_start": 1,
|
||||
"line_stop": 4,
|
||||
"line_start": 4,
|
||||
"line_stop": 20,
|
||||
"col_start": 1,
|
||||
"col_stop": 2,
|
||||
"path": "",
|
||||
"content": "function main() {\n...\n}\n"
|
||||
"content": "function main() {\n...\n} \n\n\n\n\n\n\n\n\n\n\n\n\n\n"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,20 @@
|
||||
circuit Foo {
|
||||
f: u8,
|
||||
}
|
||||
function main() {
|
||||
let x = 10u32;
|
||||
x += 20;
|
||||
console.assert(x == 30u32);
|
||||
|
||||
let y = [1u8, 2u8];
|
||||
y[0] += 3u8;
|
||||
console.assert(y[0] == 4u8);
|
||||
|
||||
let z = (1u8, 2u8);
|
||||
z.1 += 3u8;
|
||||
console.assert(z.1 == 5u8);
|
||||
|
||||
let foo = Foo { f: 6u8 };
|
||||
foo.f += 2u8;
|
||||
console.assert(foo.f == 8u8);
|
||||
}
|
Loading…
Reference in New Issue
Block a user