mirror of
https://github.com/AleoHQ/leo.git
synced 2024-12-21 00:21:47 +03:00
fix array around 1 element array dim size
This commit is contained in:
parent
2c30cba70f
commit
9a45c2ae99
@ -75,6 +75,8 @@ impl ParserContext<'_> {
|
|||||||
})?;
|
})?;
|
||||||
if dims.is_empty() && !had_item_err {
|
if dims.is_empty() && !had_item_err {
|
||||||
self.emit_err(ParserError::array_tuple_dimensions_empty(&span));
|
self.emit_err(ParserError::array_tuple_dimensions_empty(&span));
|
||||||
|
} else if dims.len() == 1 {
|
||||||
|
self.emit_err(ParserError::invalid_parens_around_single_array_dimension_size(&span));
|
||||||
}
|
}
|
||||||
ArrayDimensions(dims.into())
|
ArrayDimensions(dims.into())
|
||||||
})
|
})
|
||||||
|
@ -390,4 +390,12 @@ create_errors!(
|
|||||||
msg: "do not put parens around single variable names",
|
msg: "do not put parens around single variable names",
|
||||||
help: None,
|
help: None,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// For when a user puts parens around a single defined variable.
|
||||||
|
@formatted
|
||||||
|
invalid_parens_around_single_array_dimension_size {
|
||||||
|
args: (),
|
||||||
|
msg: "do not put parens around single dimension array size",
|
||||||
|
help: None,
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
@ -45,27 +45,6 @@ outputs:
|
|||||||
col_stop: 7
|
col_stop: 7
|
||||||
path: ""
|
path: ""
|
||||||
content: "[0; 1]"
|
content: "[0; 1]"
|
||||||
- ArrayInit:
|
|
||||||
element:
|
|
||||||
Value:
|
|
||||||
Implicit:
|
|
||||||
- "0"
|
|
||||||
- span:
|
|
||||||
line_start: 1
|
|
||||||
line_stop: 1
|
|
||||||
col_start: 2
|
|
||||||
col_stop: 3
|
|
||||||
path: ""
|
|
||||||
content: "[0; (1)]"
|
|
||||||
dimensions:
|
|
||||||
- value: "1"
|
|
||||||
span:
|
|
||||||
line_start: 1
|
|
||||||
line_stop: 1
|
|
||||||
col_start: 1
|
|
||||||
col_stop: 9
|
|
||||||
path: ""
|
|
||||||
content: "[0; (1)]"
|
|
||||||
- ArrayInit:
|
- ArrayInit:
|
||||||
element:
|
element:
|
||||||
Value:
|
Value:
|
||||||
|
@ -5,3 +5,4 @@ outputs:
|
|||||||
- "Error [EPAR0370010]: illegal spread in array initializer\n --> test:1:1\n |\n 1 | [...0u8; 1]\n | ^^^^^^^"
|
- "Error [EPAR0370010]: illegal spread in array initializer\n --> test:1:1\n |\n 1 | [...0u8; 1]\n | ^^^^^^^"
|
||||||
- "Error [EPAR0370010]: illegal spread in array initializer\n --> test:1:1\n |\n 1 | [...0; 1]\n | ^^^^^"
|
- "Error [EPAR0370010]: illegal spread in array initializer\n --> test:1:1\n |\n 1 | [...0; 1]\n | ^^^^^"
|
||||||
- "Error [EPAR0370023]: Array dimensions specified as a tuple cannot be empty.\n --> test:1:5\n |\n 1 | [0; ()]\n | ^^"
|
- "Error [EPAR0370023]: Array dimensions specified as a tuple cannot be empty.\n --> test:1:5\n |\n 1 | [0; ()]\n | ^^"
|
||||||
|
- "Error [EPAR0370045]: do not put parens around single dimension array size\n --> test:1:5\n |\n 1 | [0; (1)]\n | ^^^"
|
||||||
|
@ -89,49 +89,6 @@ outputs:
|
|||||||
col_stop: 13
|
col_stop: 13
|
||||||
path: ""
|
path: ""
|
||||||
content: "[0; 1].len()"
|
content: "[0; 1].len()"
|
||||||
- Call:
|
|
||||||
function:
|
|
||||||
Access:
|
|
||||||
Member:
|
|
||||||
inner:
|
|
||||||
ArrayInit:
|
|
||||||
element:
|
|
||||||
Value:
|
|
||||||
Implicit:
|
|
||||||
- "0"
|
|
||||||
- span:
|
|
||||||
line_start: 1
|
|
||||||
line_stop: 1
|
|
||||||
col_start: 2
|
|
||||||
col_stop: 3
|
|
||||||
path: ""
|
|
||||||
content: "[0; (1)].len()"
|
|
||||||
dimensions:
|
|
||||||
- value: "1"
|
|
||||||
span:
|
|
||||||
line_start: 1
|
|
||||||
line_stop: 1
|
|
||||||
col_start: 1
|
|
||||||
col_stop: 9
|
|
||||||
path: ""
|
|
||||||
content: "[0; (1)].len()"
|
|
||||||
name: "{\"name\":\"len\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":10,\\\"col_stop\\\":13,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"[0; (1)].len()\\\"}\"}"
|
|
||||||
span:
|
|
||||||
line_start: 1
|
|
||||||
line_stop: 1
|
|
||||||
col_start: 1
|
|
||||||
col_stop: 13
|
|
||||||
path: ""
|
|
||||||
content: "[0; (1)].len()"
|
|
||||||
type_: ~
|
|
||||||
arguments: []
|
|
||||||
span:
|
|
||||||
line_start: 1
|
|
||||||
line_stop: 1
|
|
||||||
col_start: 1
|
|
||||||
col_stop: 15
|
|
||||||
path: ""
|
|
||||||
content: "[0; (1)].len()"
|
|
||||||
- Call:
|
- Call:
|
||||||
function:
|
function:
|
||||||
Access:
|
Access:
|
||||||
|
@ -7,8 +7,6 @@ expectation: Pass
|
|||||||
|
|
||||||
[0; 1]
|
[0; 1]
|
||||||
|
|
||||||
[0; (1)]
|
|
||||||
|
|
||||||
[0; (1, 2)]
|
[0; (1, 2)]
|
||||||
|
|
||||||
[0; (1, 2,)]
|
[0; (1, 2,)]
|
||||||
|
@ -9,3 +9,5 @@ expectation: Fail
|
|||||||
[...0; 1]
|
[...0; 1]
|
||||||
|
|
||||||
[0; ()]
|
[0; ()]
|
||||||
|
|
||||||
|
[0; (1)]
|
@ -7,8 +7,6 @@ expectation: Pass
|
|||||||
|
|
||||||
[0; 1].len()
|
[0; 1].len()
|
||||||
|
|
||||||
[0; (1)].len()
|
|
||||||
|
|
||||||
[0; (1, 2)].len()
|
[0; (1, 2)].len()
|
||||||
|
|
||||||
[0; (1, 2, 3)].len()
|
[0; (1, 2, 3)].len()
|
||||||
|
Loading…
Reference in New Issue
Block a user