authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-04-20 17:25:26-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-04-20 17:25:26-07:00
logae600d2f7f89989c297c036f189b7bedfde910af
treee3440d87c859553fc3c3c60ed612cf5fa0f8af24
parent6acc354957752e2cfa8d67bdd0e4c3b42f9be3c3

fix undeclared identifier not marking function as impure


2 files changed, 10 insertions(+), 0 deletions(-)

src/analyze.cpp+1
...@@ -2814,6 +2814,7 @@ static TypeTableEntry *analyze_symbol_expr(CodeGen *g, ImportTableEntry *import,...@@ -2814,6 +2814,7 @@ static TypeTableEntry *analyze_symbol_expr(CodeGen *g, ImportTableEntry *import,
2814 return g->builtin_types.entry_invalid;2814 return g->builtin_types.entry_invalid;
2815 }2815 }
28162816
2817 mark_impure_fn(context);
2817 add_node_error(g, node, buf_sprintf("use of undeclared identifier '%s'", buf_ptr(variable_name)));2818 add_node_error(g, node, buf_sprintf("use of undeclared identifier '%s'", buf_ptr(variable_name)));
2818 return g->builtin_types.entry_invalid;2819 return g->builtin_types.entry_invalid;
2819}2820}
test/run_tests.cpp+9
...@@ -1209,6 +1209,15 @@ const a = get_it();...@@ -1209,6 +1209,15 @@ const a = get_it();
1209#static_eval_enable(false)1209#static_eval_enable(false)
1210fn get_it() -> Foo { Foo {.x = 13} }1210fn get_it() -> Foo { Foo {.x = 13} }
1211 )SOURCE", 1, ".tmp_source.zig:5:17: error: unable to evaluate constant expression");1211 )SOURCE", 1, ".tmp_source.zig:5:17: error: unable to evaluate constant expression");
1212
1213 add_compile_fail_case("undeclared identifier error should mark fn as impure", R"SOURCE(
1214fn foo() {
1215 test_a_thing();
1216}
1217fn test_a_thing() {
1218 bad_fn_call();
1219}
1220 )SOURCE", 1, ".tmp_source.zig:6:5: error: use of undeclared identifier 'bad_fn_call'");
1212}1221}
12131222
1214//////////////////////////////////////////////////////////////////////////////1223//////////////////////////////////////////////////////////////////////////////