forked from FuelLabs/sway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LSP tests for
TyFunctionDeclaration
(FuelLabs#4031)
## Description Adds go to definition and hover doc comment tests for the `TyFunctionDeclaration` type. While working on this I noticed we aren't collecting tokens in function parameters and return type with generic types. I've opened up FuelLabs#4030 for this to be addressed. Works towards FuelLabs#3989
- Loading branch information
1 parent
1e37122
commit 9a00b5a
Showing
4 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
out | ||
target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[project] | ||
authors = ["Fuel Labs <[email protected]>"] | ||
entry = "main.sw" | ||
license = "Apache-2.0" | ||
name = "functions" | ||
|
||
[dependencies] | ||
std = { path = "../../../../../sway-lib-std" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
contract; | ||
|
||
struct Point { | ||
x: u32, | ||
y: u32, | ||
} | ||
|
||
/// A simple function declaration with a struct as a return type | ||
fn foo() -> Point { | ||
Point { x: 1, y: 2 } | ||
} | ||
|
||
/// A function declaration with struct as a function parameter | ||
pub fn bar(p: Point) -> Point { | ||
Point { x: p.x, y: p.y } | ||
} | ||
|
||
// Function expressions | ||
fn test() { | ||
let p = foo(); | ||
let p2 = bar(p); | ||
} | ||
|
||
pub enum Rezult<T, E> { | ||
Ok: T, | ||
Err: E, | ||
} | ||
|
||
pub enum DumbError { | ||
Error: (), | ||
} | ||
|
||
// Function with generic types | ||
pub fn func(r: Rezult<u8, DumbError>) -> Rezult<u8, DumbError> { | ||
Rezult::Ok(1u8) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters