aboutsummaryrefslogtreecommitdiff
path: root/src/analyze.cpp
diff options
context:
space:
mode:
authorLemonBoy <thatlemon@gmail.com>2019-12-24 11:28:10 +0100
committerLemonBoy <thatlemon@gmail.com>2020-01-02 18:53:20 +0100
commit271fc6a2479a1c5f2f914c1c40a848bf1b9d70d8 (patch)
treec0e748428933f8755639b1cb4addf40d027348f3 /src/analyze.cpp
parent563d9ebfe597b313b265a5a30296c081fe35d87a (diff)
downloadzig-271fc6a2479a1c5f2f914c1c40a848bf1b9d70d8.tar.gz
zig-271fc6a2479a1c5f2f914c1c40a848bf1b9d70d8.zip
Catch more errors during the type resolution phase
Returning the uninitialized/stale error condition made the compiler turn a blind eye to some problems.
Diffstat (limited to 'src/analyze.cpp')
-rw-r--r--src/analyze.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp
index 7e672e1936..9a4b1449b6 100644
--- a/src/analyze.cpp
+++ b/src/analyze.cpp
@@ -2180,7 +2180,7 @@ static Error resolve_struct_type(CodeGen *g, ZigType *struct_type) {
ZigType *field_type = resolve_struct_field_type(g, field);
if (field_type == nullptr) {
struct_type->data.structure.resolve_status = ResolveStatusInvalid;
- return err;
+ return ErrorSemanticAnalyzeFail;
}
if ((err = type_resolve(g, field->type_entry, ResolveStatusSizeKnown))) {
struct_type->data.structure.resolve_status = ResolveStatusInvalid;
@@ -2270,7 +2270,7 @@ static Error resolve_struct_type(CodeGen *g, ZigType *struct_type) {
ZigType *field_type = resolve_struct_field_type(g, field);
if (field_type == nullptr) {
struct_type->data.structure.resolve_status = ResolveStatusInvalid;
- return err;
+ return ErrorSemanticAnalyzeFail;
}
if ((err = type_resolve(g, field_type, ResolveStatusSizeKnown))) {
@@ -2340,7 +2340,7 @@ static Error resolve_union_alignment(CodeGen *g, ZigType *union_type) {
&field->align))
{
union_type->data.unionation.resolve_status = ResolveStatusInvalid;
- return err;
+ return ErrorSemanticAnalyzeFail;
}
add_node_error(g, field->decl_node,
buf_create_from_str("TODO implement field alignment syntax for unions. https://github.com/ziglang/zig/issues/3125"));
@@ -2467,6 +2467,7 @@ static Error resolve_union_type(CodeGen *g, ZigType *union_type) {
union_type->data.unionation.resolve_status = ResolveStatusInvalid;
return ErrorSemanticAnalyzeFail;
}
+
if (is_packed) {
if ((err = emit_error_unless_type_allowed_in_packed_union(g, field_type, union_field->decl_node))) {
union_type->data.unionation.resolve_status = ResolveStatusInvalid;
@@ -2925,7 +2926,7 @@ static Error resolve_struct_alignment(CodeGen *g, ZigType *struct_type) {
&field->align))
{
struct_type->data.structure.resolve_status = ResolveStatusInvalid;
- return err;
+ return ErrorSemanticAnalyzeFail;
}
} else if (packed) {
field->align = 1;