diff --git a/fine/src/semantics.rs b/fine/src/semantics.rs index a3c893ef..6f3fcff2 100644 --- a/fine/src/semantics.rs +++ b/fine/src/semantics.rs @@ -653,7 +653,6 @@ impl<'a> Semantics<'a> { TreeKind::LetStatement => Some(Type::Nothing), TreeKind::ReturnStatement => Some(Type::Unreachable), TreeKind::ExpressionStatement => self.type_of_expression_statement(tree), - TreeKind::IfStatement => self.type_of_if_statement(tree), TreeKind::Identifier => self.type_of_identifier(t, tree), TreeKind::FunctionDecl => self.type_of_function_decl(tree), @@ -1021,10 +1020,6 @@ impl<'a> Semantics<'a> { Some(Type::Function(parameter_types, return_type)) } - fn type_of_if_statement(&self, tree: &Tree) -> Option { - Some(self.type_of(tree.nth_tree(0)?)) - } - pub fn dump_compiler_state(&self, tr: Option) { eprintln!("Parsed the tree as:"); eprintln!("\n{}", self.syntax_tree.dump(true)); diff --git a/fine/tests/expression/boolean.fine b/fine/tests/expression/boolean.fine index 60280dbf..abf299d4 100644 --- a/fine/tests/expression/boolean.fine +++ b/fine/tests/expression/boolean.fine @@ -1,61 +1,24 @@ -fun test() { - true and false or false and !true -} +true and false or false and !true; // @no-errors -// @compiles-to: -// | function test (0 args, 0 locals): -// | strings (0): -// | code (15): -// | 0: PushTrue -// | 1: JumpFalse(4) -// | 2: PushTrue -// | 3: Jump(5) -// | 4: PushFalse -// | 5: JumpTrue(8) -// | 6: PushTrue -// | 7: Jump(14) -// | 8: PushFalse -// | 9: JumpFalse(12) -// | 10: PushTrue -// | 11: Jump(14) -// | 12: PushTrue -// | 13: BoolNot -// | 14: Return -// | function << module >> (0 args, 0 locals): -// | strings (0): -// | code (2): -// | 0: PushNothing -// | 1: Return -// | -// @eval: Bool(false) // @type: 15 bool // @concrete: // | File -// | FunctionDecl -// | Fun:'"fun"' -// | Identifier:'"test"' -// | ParamList -// | LeftParen:'"("' -// | RightParen:'")"' -// | Block -// | LeftBrace:'"{"' -// | ExpressionStatement -// | BinaryExpression -// | BinaryExpression -// | LiteralExpression -// | True:'"true"' -// | And:'"and"' -// | LiteralExpression -// | False:'"false"' -// | Or:'"or"' -// | BinaryExpression -// | LiteralExpression -// | False:'"false"' -// | And:'"and"' -// | UnaryExpression -// | Bang:'"!"' -// | LiteralExpression -// | True:'"true"' -// | RightBrace:'"}"' -// +// | ExpressionStatement +// | BinaryExpression +// | BinaryExpression +// | LiteralExpression +// | True:'"true"' +// | And:'"and"' +// | LiteralExpression +// | False:'"false"' +// | Or:'"or"' +// | BinaryExpression +// | LiteralExpression +// | False:'"false"' +// | And:'"and"' +// | UnaryExpression +// | Bang:'"!"' +// | LiteralExpression +// | True:'"true"' +// | Semicolon:'";"' diff --git a/fine/tests/expression/conditional.fine b/fine/tests/expression/conditional.fine index a7ed78fc..9f948fe7 100644 --- a/fine/tests/expression/conditional.fine +++ b/fine/tests/expression/conditional.fine @@ -1,59 +1,51 @@ -fun test() { - if true { "discarded"; 23 } else { 45 } -} +if true { "discarded"; 23 } else { 45 } // @no-errors // Here come some type probes! // (type of the condition) -// @type: 20 bool +// @type: 3 bool // // (the discarded expression) -// @type: 27 string +// @type: 10 string // // (the "then" clause) -// @type: 40 f64 -// @type: 43 f64 +// @type: 23 f64 +// @type: 26 f64 // // (the "else" clause) -// @type: 52 f64 -// @type: 55 f64 +// @type: 35 f64 +// @type: 38 f64 +// +// (the overall expression) +// @type: 0 f64 // // @concrete: // | File -// | FunctionDecl -// | Fun:'"fun"' -// | Identifier:'"test"' -// | ParamList -// | LeftParen:'"("' -// | RightParen:'")"' -// | Block -// | LeftBrace:'"{"' -// | IfStatement -// | ConditionalExpression -// | If:'"if"' +// | IfStatement +// | ConditionalExpression +// | If:'"if"' +// | LiteralExpression +// | True:'"true"' +// | Block +// | LeftBrace:'"{"' +// | ExpressionStatement // | LiteralExpression -// | True:'"true"' -// | Block -// | LeftBrace:'"{"' -// | ExpressionStatement -// | LiteralExpression -// | String:'"\"discarded\""' -// | Semicolon:'";"' -// | ExpressionStatement -// | LiteralExpression -// | Number:'"23"' -// | RightBrace:'"}"' -// | Else:'"else"' -// | Block -// | LeftBrace:'"{"' -// | ExpressionStatement -// | LiteralExpression -// | Number:'"45"' -// | RightBrace:'"}"' -// | RightBrace:'"}"' +// | String:'"\"discarded\""' +// | Semicolon:'";"' +// | ExpressionStatement +// | LiteralExpression +// | Number:'"23"' +// | RightBrace:'"}"' +// | Else:'"else"' +// | Block +// | LeftBrace:'"{"' +// | ExpressionStatement +// | LiteralExpression +// | Number:'"45"' +// | RightBrace:'"}"' // // @compiles-to: -// | function test (0 args, 0 locals): +// | function << module >> (0 args, 0 locals): // | strings (1): // | 0: "discarded" // | code (8): @@ -65,10 +57,4 @@ fun test() { // | 5: Jump(7) // | 6: PushFloat(45.0) // | 7: Return -// | function << module >> (0 args, 0 locals): -// | strings (0): -// | code (2): -// | 0: PushNothing -// | 1: Return // | -// @eval: Float(23.0)