-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds type-checking to the following cases: - block outputs (reflect the type of the last statement, none otherwise) - parameters in def (any if not specified, else the specified type) - if else (reflect the type of the blocks if the blocks are equal, if they are unequal then forbidden, and the if branch type otherwise) --------- Signed-off-by: innocentzero <[email protected]>
- Loading branch information
1 parent
44fcadf
commit eba4f27
Showing
35 changed files
with
592 additions
and
134 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,25 @@ | ||
--- | ||
source: src/test.rs | ||
expression: evaluate_example(path) | ||
input_file: tests/alias.nu | ||
snapshot_kind: text | ||
--- | ||
==== COMPILER ==== | ||
0: Name (4 to 7) "foo" | ||
1: Name (9 to 10) "a" | ||
2: Param { name: NodeId(1), ty: None } (9 to 10) | ||
3: Params([NodeId(2)]) (8 to 11) | ||
4: Variable (14 to 16) "$a" | ||
5: Block(BlockId(0)) (12 to 18) | ||
6: Def { name: NodeId(0), params: NodeId(3), return_ty: None, block: NodeId(5) } (0 to 18) | ||
7: Name (20 to 25) "alias" | ||
8: Name (26 to 29) "bar" | ||
9: Garbage (30 to 31) | ||
10: String (32 to 35) "foo" | ||
11: Call { parts: [NodeId(7), NodeId(8), NodeId(9), NodeId(10)] } (26 to 35) | ||
12: Name (37 to 40) "bar" | ||
13: Int (41 to 42) "1" | ||
14: Call { parts: [NodeId(12), NodeId(13)] } (41 to 42) | ||
15: Block(BlockId(1)) (0 to 43) | ||
==== COMPILER ERRORS ==== | ||
Error (NodeId 9): incomplete expression |
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
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
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
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
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,61 @@ | ||
--- | ||
source: src/test.rs | ||
expression: evaluate_example(path) | ||
input_file: tests/closure3.nu | ||
snapshot_kind: text | ||
--- | ||
==== COMPILER ==== | ||
0: Variable (4 to 11) "closure" | ||
1: Name (16 to 17) "a" | ||
2: Name (19 to 22) "int" | ||
3: Type { name: NodeId(2), params: None, optional: false } (19 to 22) | ||
4: Param { name: NodeId(1), ty: Some(NodeId(3)) } (16 to 22) | ||
5: Name (24 to 25) "b" | ||
6: Name (27 to 30) "int" | ||
7: Type { name: NodeId(6), params: None, optional: false } (27 to 30) | ||
8: Param { name: NodeId(5), ty: Some(NodeId(7)) } (24 to 30) | ||
9: Params([NodeId(4), NodeId(8)]) (15 to 31) | ||
10: Variable (32 to 34) "$a" | ||
11: Plus (35 to 36) | ||
12: Variable (37 to 39) "$b" | ||
13: LessThan (40 to 41) | ||
14: Int (42 to 43) "5" | ||
15: BinaryOp { lhs: NodeId(10), op: NodeId(11), rhs: NodeId(12) } (32 to 39) | ||
16: BinaryOp { lhs: NodeId(15), op: NodeId(13), rhs: NodeId(14) } (32 to 43) | ||
17: Block(BlockId(0)) (32 to 43) | ||
18: Closure { params: Some(NodeId(9)), block: NodeId(17) } (14 to 44) | ||
19: Let { variable_name: NodeId(0), ty: None, initializer: NodeId(18), is_mutable: false } (0 to 44) | ||
20: Name (46 to 52) "filter" | ||
21: Variable (53 to 61) "$closure" | ||
22: Call { parts: [NodeId(20), NodeId(21)] } (53 to 61) | ||
23: Block(BlockId(1)) (0 to 62) | ||
==== SCOPE ==== | ||
0: Frame Scope, node_id: NodeId(23) | ||
variables: [ closure: NodeId(0) ] | ||
1: Frame Scope, node_id: NodeId(17) | ||
variables: [ a: NodeId(1), b: NodeId(5) ] | ||
==== TYPES ==== | ||
0: closure | ||
1: unknown | ||
2: unknown | ||
3: int | ||
4: int | ||
5: unknown | ||
6: unknown | ||
7: int | ||
8: int | ||
9: forbidden | ||
10: int | ||
11: forbidden | ||
12: int | ||
13: forbidden | ||
14: int | ||
15: int | ||
16: bool | ||
17: bool | ||
18: closure | ||
19: () | ||
20: unknown | ||
21: closure | ||
22: stream<binary> | ||
23: stream<binary> |
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
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
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
Oops, something went wrong.