diff options
| author | pfg <pfg@pfg.pw> | 2020-10-13 22:29:41 -0700 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2020-11-18 21:45:51 +0200 |
| commit | cf7de64f1a136c9208284362db6cc1d3c81f1111 (patch) | |
| tree | 602f18d3b83d39d83a76e0d082b9a25d24bf3bc0 /src | |
| parent | 663e112773f91ccbff9f9825147b1a2c0bb5e00c (diff) | |
| download | zig-cf7de64f1a136c9208284362db6cc1d3c81f1111.tar.gz zig-cf7de64f1a136c9208284362db6cc1d3c81f1111.zip | |
stage1: improve error for missing a number type on a runtime var
Diffstat (limited to 'src')
| -rw-r--r-- | src/stage1/ir.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/stage1/ir.cpp b/src/stage1/ir.cpp index 738ef3c65d..2ed6675930 100644 --- a/src/stage1/ir.cpp +++ b/src/stage1/ir.cpp @@ -18804,9 +18804,12 @@ static IrInstGen *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstSrcDeclV case ReqCompTimeYes: var_class_requires_const = true; if (!var->gen_is_const && !is_comptime_var) { - ir_add_error_node(ira, source_node, + ErrorMsg *msg = ir_add_error_node(ira, source_node, buf_sprintf("variable of type '%s' must be const or comptime", buf_ptr(&result_type->name))); + if(result_type->id == ZigTypeIdComptimeInt || result_type -> id == ZigTypeIdComptimeFloat) { + add_error_note(ira->codegen, msg, source_node, buf_sprintf("to modify this variable at runtime, it must be given an explicit fixed-size number type")); + } result_type = ira->codegen->builtin_types.entry_invalid; } break; |
