mirror of
https://github.com/AleoHQ/leo.git
synced 2024-12-29 20:44:52 +03:00
feat(ast): handle the empty tuple type
Signed-off-by: ljedrz <ljedrz@gmail.com>
This commit is contained in:
parent
e2f0848773
commit
d1ee66a747
@ -226,7 +226,7 @@ dimension_single = {
|
|||||||
// Declared in types/array_dimensions.rs
|
// Declared in types/array_dimensions.rs
|
||||||
dimension_multiple = { "(" ~ number_positive ~ ("," ~ number_positive)* ~ ")"}
|
dimension_multiple = { "(" ~ number_positive ~ ("," ~ number_positive)* ~ ")"}
|
||||||
|
|
||||||
type_tuple = { "(" ~ NEWLINE* ~ type_ ~ ("," ~ NEWLINE* ~ type_)+ ~ ","? ~ NEWLINE* ~ ")" }
|
type_tuple = { "(" ~ NEWLINE* ~ (type_ ~ ("," ~ NEWLINE* ~ type_)+ ~ ","?)? ~ NEWLINE* ~ ")" }
|
||||||
|
|
||||||
/// Values
|
/// Values
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ fn access() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn unit() {
|
fn implicit_unit() {
|
||||||
parses_to! {
|
parses_to! {
|
||||||
parser: LanguageParser,
|
parser: LanguageParser,
|
||||||
input: "()",
|
input: "()",
|
||||||
@ -69,3 +69,23 @@ fn unit() {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn explicit_unit() {
|
||||||
|
parses_to! {
|
||||||
|
parser: LanguageParser,
|
||||||
|
input: "let x: () = ();",
|
||||||
|
rule: Rule::statement_definition,
|
||||||
|
tokens: [
|
||||||
|
statement_definition(0, 15, [
|
||||||
|
declare(0, 4, [let_(0, 4, [])]),
|
||||||
|
variables(4, 9, [
|
||||||
|
variable_name(4, 5, [identifier(4, 5, [])]),
|
||||||
|
type_(7, 9, [type_tuple(7, 9, [])])
|
||||||
|
]),
|
||||||
|
expression(12, 14, [expression_term(12, 14, [expression_tuple(12, 14, [])])]),
|
||||||
|
LINE_END(14, 15, [])
|
||||||
|
])
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user