Skip to content

Commit

Permalink
Add test for return statements in functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Glyphack committed Aug 6, 2023
1 parent 17f80be commit e08f6c8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
1 change: 1 addition & 0 deletions typechecker/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ mod tests {
"a += b",
"def f():
a = 1
return
",
];
for source in sources {
Expand Down
4 changes: 1 addition & 3 deletions typechecker/src/semantic_analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,9 +444,7 @@ impl TraversalVisitor for SemanticAnalyzer {
todo!()
}

fn visit_return(&mut self, r: &parser::ast::Return) {
todo!()
}
fn visit_return(&mut self, r: &parser::ast::Return) {}

fn visit_raise(&mut self, r: &parser::ast::Raise) {
todo!()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ SymbolTable {
SymbolTableScope {
symbol_table_type: Module,
symbols: {
"c": SymbolTableNode {
name: "c",
"d": SymbolTableNode {
name: "d",
declarations: [
Variable(
Variable {
Expand Down Expand Up @@ -63,8 +63,8 @@ SymbolTable {
module_hidden: false,
implicit: false,
},
"d": SymbolTableNode {
name: "d",
"c": SymbolTableNode {
name: "c",
declarations: [
Variable(
Variable {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: typechecker/src/build.rs
description: "def f():\n a = 1\n"
description: "def f():\n a = 1\n return\n"
---
SymbolTable {
scopes: [
Expand All @@ -16,12 +16,20 @@ SymbolTable {
module_name: "test",
node: Node {
start: 0,
end: 18,
end: 28,
},
},
is_method: false,
is_generator: false,
return_statements: [],
return_statements: [
Return {
node: Node {
start: 18,
end: 27,
},
value: None,
},
],
yeild_statements: [],
raise_statements: [],
},
Expand Down

0 comments on commit e08f6c8

Please sign in to comment.