diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-04-10 13:18:42 -0700 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-04-10 13:18:42 -0700 |
| commit | b117b5907c50f495c53770bfc351e0431e6474b3 (patch) | |
| tree | 38565c201e7dd562fc10db66f9f15b56d424a2d1 /src/analyze.cpp | |
| parent | 0683bd8bf66c00d38f79d49319b5d80ac1f9a470 (diff) | |
| download | zig-b117b5907c50f495c53770bfc351e0431e6474b3.tar.gz zig-b117b5907c50f495c53770bfc351e0431e6474b3.zip | |
add error for accessing empty array
closes #134
Diffstat (limited to 'src/analyze.cpp')
| -rw-r--r-- | src/analyze.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp index 321915d6ea..222874b875 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -2445,6 +2445,9 @@ static TypeTableEntry *analyze_array_access_expr(CodeGen *g, ImportTableEntry *i if (array_type->id == TypeTableEntryIdInvalid) { return_type = g->builtin_types.entry_invalid; } else if (array_type->id == TypeTableEntryIdArray) { + if (array_type->data.array.len == 0) { + add_node_error(g, node, buf_sprintf("out of bounds array access")); + } return_type = array_type->data.array.child_type; } else if (array_type->id == TypeTableEntryIdPointer) { return_type = array_type->data.pointer.child_type; |
