| author | |
| committer | |
| log | ae600d2f7f89989c297c036f189b7bedfde910af |
| tree | e3440d87c859553fc3c3c60ed612cf5fa0f8af24 |
| parent | 6acc354957752e2cfa8d67bdd0e4c3b42f9be3c3 |
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 | } |
| 2816 | 2816 | ||
| 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) |
| 1210 | fn get_it() -> Foo { Foo {.x = 13} } | 1210 | fn 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( | ||
| 1214 | fn foo() { | ||
| 1215 | test_a_thing(); | ||
| 1216 | } | ||
| 1217 | fn 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 | } |
| 1213 | 1222 | ||
| 1214 | ////////////////////////////////////////////////////////////////////////////// | 1223 | ////////////////////////////////////////////////////////////////////////////// |