authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-01-02 00:09:49-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-01-02 00:09:49-07:00
log724dcdd384c6c00b9e39ed67867d364287e45f0a
tree42e617f280fc3016933ad8197b32d82efede1ed6
parent9a8851515b8aeac1adcea38094a45e3260e7522c

error for if var expression not maybe type


2 files changed, 7 insertions(+), 1 deletions(-)

src/analyze.cpp+1-1
......@@ -1333,7 +1333,7 @@ static VariableTableEntry *analyze_variable_declaration_raw(CodeGen *g, ImportTa
13331333 if (implicit_type->id == TypeTableEntryIdMaybe) {
13341334 implicit_type = implicit_type->data.maybe.child_type;
13351335 } else {
1336 add_node_error(g, source_node, buf_sprintf("expected maybe type"));
1336 add_node_error(g, variable_declaration->expr, buf_sprintf("expected maybe type"));
13371337 implicit_type = g->builtin_types.entry_invalid;
13381338 }
13391339 } else if (implicit_type->id == TypeTableEntryIdUnreachable) {
test/run_tests.cpp+6
......@@ -982,6 +982,12 @@ fn f() {
982982 continue;
983983}
984984 )SOURCE", 1, ".tmp_source.zig:3:5: error: 'continue' expression not in loop");
985
986 add_compile_fail_case("invalid maybe type", R"SOURCE(
987fn f() {
988 if (const x ?= true) { }
989}
990 )SOURCE", 1, ".tmp_source.zig:3:20: error: expected maybe type");
985991}
986992
987993static void print_compiler_invocation(TestCase *test_case) {