added block expression
This commit is contained in:
@@ -91,7 +91,7 @@ class VariableUsage:
|
||||
|
||||
@dataclass
|
||||
class Expression:
|
||||
expression: Union[LiteralInt, LiteralFloat, FunctionCall, VariableUsage, Operation]
|
||||
expression: Union[LiteralInt, LiteralFloat, FunctionCall, "Block", VariableUsage, Operation]
|
||||
type: TypeUsage
|
||||
|
||||
|
||||
@@ -163,6 +163,7 @@ boring_grammar = r"""
|
||||
| variable_usage
|
||||
| function_call
|
||||
| "(" expression ")"
|
||||
| block
|
||||
|
||||
let_statement : "let" identifier "=" expression ";"
|
||||
| "let" identifier ":" type_usage "=" expression ";"
|
||||
|
||||
@@ -139,6 +139,10 @@ class TypeChecker:
|
||||
if self.with_function_call(env, type_env, subexpression):
|
||||
changed = True
|
||||
return changed
|
||||
if isinstance(subexpression, parse.Block):
|
||||
if self.with_block(env, type_env, subexpression):
|
||||
changed = True
|
||||
return changed
|
||||
if isinstance(subexpression, parse.VariableUsage):
|
||||
if self.with_variable_usage(env, type_env, subexpression):
|
||||
changed = True
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
fn add(a: I32, b: I32): I32 {
|
||||
let foo = 4;
|
||||
let test_float: F32 = 10.2;
|
||||
let test_float: F32 = {
|
||||
10.2
|
||||
};
|
||||
a + b + foo
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user