| author | |
| committer | |
| log | 3ef6663b723e7391edbe84d3df48fcc79c66bc1f |
| tree | 3e646a0719a362fd547f1f250fa0e82bff620a1e |
| parent | 110a6f39ca9cf578e014461f2e9eef2691a2368d |
4 files changed, 18 insertions(+), 26 deletions(-)
src/analyze.cpp+1-1| ... | ... | @@ -2839,7 +2839,6 @@ bool type_requires_comptime(TypeTableEntry *type_entry) { |
| 2839 | 2839 | case TypeTableEntryIdUndefLit: |
| 2840 | 2840 | case TypeTableEntryIdNullLit: |
| 2841 | 2841 | case TypeTableEntryIdMetaType: |
| 2842 | case TypeTableEntryIdVoid: | |
| 2843 | 2842 | case TypeTableEntryIdNamespace: |
| 2844 | 2843 | case TypeTableEntryIdBlock: |
| 2845 | 2844 | case TypeTableEntryIdBoundFn: |
| ... | ... | @@ -2857,6 +2856,7 @@ bool type_requires_comptime(TypeTableEntry *type_entry) { |
| 2857 | 2856 | case TypeTableEntryIdFloat: |
| 2858 | 2857 | case TypeTableEntryIdPointer: |
| 2859 | 2858 | case TypeTableEntryIdEnumTag: |
| 2859 | case TypeTableEntryIdVoid: | |
| 2860 | 2860 | return false; |
| 2861 | 2861 | } |
| 2862 | 2862 | zig_unreachable(); |
src/ir.cpp+3-3| ... | ... | @@ -6350,13 +6350,13 @@ static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node |
| 6350 | 6350 | if (casted_arg->value.type->id == TypeTableEntryIdInvalid) |
| 6351 | 6351 | return false; |
| 6352 | 6352 | |
| 6353 | ConstExprValue *first_arg_val = ir_resolve_const(ira, casted_arg, UndefBad); | |
| 6354 | if (!first_arg_val) | |
| 6353 | ConstExprValue *arg_val = ir_resolve_const(ira, casted_arg, UndefBad); | |
| 6354 | if (!arg_val) | |
| 6355 | 6355 | return false; |
| 6356 | 6356 | |
| 6357 | 6357 | Buf *param_name = param_decl_node->data.param_decl.name; |
| 6358 | 6358 | VariableTableEntry *var = add_variable(ira->codegen, param_decl_node, |
| 6359 | *exec_scope, param_name, true, first_arg_val); | |
| 6359 | *exec_scope, param_name, true, arg_val); | |
| 6360 | 6360 | *exec_scope = var->child_scope; |
| 6361 | 6361 | *next_proto_i += 1; |
| 6362 | 6362 |
test/cases/misc.zig+14| ... | ... | @@ -278,6 +278,20 @@ fn explicitCastMaybePointers() { |
| 278 | 278 | const b: ?&f32 = (?&f32)(a); |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | fn genericMallocFree() { | |
| 282 | @setFnTest(this); | |
| 283 | ||
| 284 | const a = %%memAlloc(u8, 10); | |
| 285 | memFree(u8, a); | |
| 286 | } | |
| 287 | const some_mem : [100]u8 = undefined; | |
| 288 | fn memAlloc(inline T: type, n: usize) -> %[]T { | |
| 289 | return (&T)(&some_mem[0])[0...n]; | |
| 290 | } | |
| 291 | fn memFree(inline T: type, mem: []T) { } | |
| 292 | ||
| 293 | ||
| 294 | ||
| 281 | 295 | |
| 282 | 296 | // TODO import from std.str |
| 283 | 297 | pub fn memeql(a: []const u8, b: []const u8) -> bool { |
test/self_hosted.zig-22| ... | ... | @@ -4,28 +4,6 @@ const str = std.str; |
| 4 | 4 | const cstr = std.cstr; |
| 5 | 5 | |
| 6 | 6 | |
| 7 | fn explicitCastMaybePointers() { | |
| 8 | @setFnTest(this); | |
| 9 | ||
| 10 | const a: ?&i32 = undefined; | |
| 11 | const b: ?&f32 = (?&f32)(a); | |
| 12 | } | |
| 13 | ||
| 14 | fn genericMallocFree() { | |
| 15 | @setFnTest(this, true); | |
| 16 | ||
| 17 | const a = %%memAlloc(u8, 10); | |
| 18 | memFree(u8, a); | |
| 19 | } | |
| 20 | const some_mem : [100]u8 = undefined; | |
| 21 | fn memAlloc(inline T: type, n: usize) -> %[]T { | |
| 22 | @setFnStaticEval(this, false); | |
| 23 | ||
| 24 | return (&T)(&some_mem[0])[0...n]; | |
| 25 | } | |
| 26 | fn memFree(inline T: type, mem: []T) { } | |
| 27 | ||
| 28 | ||
| 29 | 7 | fn castUndefined() { |
| 30 | 8 | @setFnTest(this, true); |
| 31 | 9 |