analysis: check current_scope being null for VarDecl
This commit is contained in:
parent
192baf0725
commit
c743c804be
2 changed files with 7 additions and 4 deletions
|
@ -184,8 +184,9 @@ pub const Analyzer = struct {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO make return type optional and so, skip exprs that
|
// TODO make return type of resolveExprType optional and so,
|
||||||
// fail to be fully resolved, instead of returning CompileError
|
// skip exprs that fail to be fully resolved, instead
|
||||||
|
// of returning CompileError
|
||||||
|
|
||||||
// TODO make the expr ptr a const since we want to implicit cast things
|
// TODO make the expr ptr a const since we want to implicit cast things
|
||||||
pub fn resolveExprType(
|
pub fn resolveExprType(
|
||||||
|
@ -387,7 +388,10 @@ pub const Analyzer = struct {
|
||||||
|
|
||||||
var var_type = try self.resolveExprType(ctx, vardecl.value);
|
var var_type = try self.resolveExprType(ctx, vardecl.value);
|
||||||
|
|
||||||
// TODO check current_scope being null
|
if (ctx.current_scope == null) {
|
||||||
|
self.doError("Can't declare without a scope");
|
||||||
|
return CompileError.Invalid;
|
||||||
|
}
|
||||||
|
|
||||||
_ = try ctx.current_scope.?.env.put(name, var_type);
|
_ = try ctx.current_scope.?.env.put(name, var_type);
|
||||||
},
|
},
|
||||||
|
|
|
@ -101,7 +101,6 @@ pub const Codegen = struct {
|
||||||
builder: var,
|
builder: var,
|
||||||
expr: *const ast.Expr,
|
expr: *const ast.Expr,
|
||||||
) anyerror!llvm.LLVMValueRef {
|
) anyerror!llvm.LLVMValueRef {
|
||||||
// TODO Assign modifies the symbol table
|
|
||||||
return switch (expr.*) {
|
return switch (expr.*) {
|
||||||
|
|
||||||
// TODO handle all literals, construct llvm values for them
|
// TODO handle all literals, construct llvm values for them
|
||||||
|
|
Loading…
Reference in a new issue