Use rust-style type parameter syntax
This commit is contained in:
parent
37d54499da
commit
97268c272e
@ -82,8 +82,8 @@ pub fn parser<'src>(
|
||||
.at_least(1)
|
||||
.collect()
|
||||
.delimited_by(
|
||||
just(Token::Symbol(Symbol::Pipe)),
|
||||
just(Token::Symbol(Symbol::Pipe)),
|
||||
just(Token::Symbol(Symbol::Less)),
|
||||
just(Token::Symbol(Symbol::Greater)),
|
||||
)
|
||||
.or_not(),
|
||||
)
|
||||
@ -281,8 +281,8 @@ pub fn parser<'src>(
|
||||
.allow_trailing()
|
||||
.collect()
|
||||
.delimited_by(
|
||||
just(Token::Symbol(Symbol::Pipe)),
|
||||
just(Token::Symbol(Symbol::Pipe)),
|
||||
just(Token::Symbol(Symbol::Less)),
|
||||
just(Token::Symbol(Symbol::Greater)),
|
||||
)
|
||||
.or_not(),
|
||||
)
|
||||
|
@ -467,7 +467,7 @@ fn list_of_type() {
|
||||
#[test]
|
||||
fn function_type() {
|
||||
assert_eq!(
|
||||
parse(&lex("type Foo = fn |T| (x: int)").unwrap()).unwrap()[0],
|
||||
parse(&lex("type Foo = fn <T> (x: int)").unwrap()).unwrap()[0],
|
||||
Statement::TypeAlias(
|
||||
TypeAlias::new(
|
||||
Identifier::new("Foo").with_position((5, 8)),
|
||||
@ -493,7 +493,7 @@ fn function_type() {
|
||||
#[test]
|
||||
fn function_type_with_return() {
|
||||
assert_eq!(
|
||||
parse(&lex("type Foo = fn |T| (x: int) -> T").unwrap()).unwrap()[0],
|
||||
parse(&lex("type Foo = fn <T> (x: int) -> T").unwrap()).unwrap()[0],
|
||||
Statement::TypeAlias(
|
||||
TypeAlias::new(
|
||||
Identifier::new("Foo").with_position((5, 8)),
|
||||
@ -537,7 +537,7 @@ fn function_call() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn function_call_with_type_arguments() {
|
||||
fn function_call_with_arguments() {
|
||||
assert_eq!(
|
||||
parse(&lex("foobar::<str>('hi')").unwrap()).unwrap()[0],
|
||||
Statement::Expression(Expression::FunctionCall(
|
||||
@ -610,7 +610,7 @@ fn function() {
|
||||
#[test]
|
||||
fn function_with_type_arguments() {
|
||||
assert_eq!(
|
||||
parse(&lex("fn |T, U| (x: T, y: U) -> T { x }").unwrap()).unwrap()[0],
|
||||
parse(&lex("fn <T, U> (x: T, y: U) -> T { x }").unwrap()).unwrap()[0],
|
||||
Statement::Expression(Expression::Value(
|
||||
ValueNode::function(
|
||||
Some(vec![Identifier::new("T"), Identifier::new("U"),]),
|
||||
|
@ -6,7 +6,7 @@ fn function_call_with_type_argument() {
|
||||
interpret(
|
||||
"test",
|
||||
"
|
||||
foobar = fn |T| (x: T) -> T { x }
|
||||
foobar = fn <T> (x: T) -> T { x }
|
||||
foobar::<int>(42)
|
||||
",
|
||||
),
|
||||
|
@ -1,5 +1,5 @@
|
||||
json = {
|
||||
parse = fn |T| (input: str) -> T {
|
||||
parse = fn <T> (input: str) -> T {
|
||||
__JSON_PARSE__::<T>(input)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user