| ... | @@ -364,6 +364,9 @@ fn analyzeInstEnsureResultNonError(mod: *Module, scope: *Scope, inst: *zir.Inst. | ... | @@ -364,6 +364,9 @@ fn analyzeInstEnsureResultNonError(mod: *Module, scope: *Scope, inst: *zir.Inst. |
| 364 | | 364 | |
| 365 | fn analyzeInstAlloc(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { | 365 | fn analyzeInstAlloc(mod: *Module, scope: *Scope, inst: *zir.Inst.UnOp) InnerError!*Inst { |
| 366 | const var_type = try resolveType(mod, scope, inst.positionals.operand); | 366 | const var_type = try resolveType(mod, scope, inst.positionals.operand); |
| | 367 | if (!var_type.isValidVarType()) { |
| | 368 | return mod.fail(scope, inst.base.src, "variable of type '{}' must be const or comptime", .{var_type}); |
| | 369 | } |
| 367 | const ptr_type = try mod.singlePtrType(scope, inst.base.src, true, var_type); | 370 | const ptr_type = try mod.singlePtrType(scope, inst.base.src, true, var_type); |
| 368 | const b = try mod.requireRuntimeBlock(scope, inst.base.src); | 371 | const b = try mod.requireRuntimeBlock(scope, inst.base.src); |
| 369 | return mod.addNoOp(b, inst.base.src, ptr_type, .alloc); | 372 | return mod.addNoOp(b, inst.base.src, ptr_type, .alloc); |
| ... | @@ -760,7 +763,12 @@ fn analyzeInstFnType(mod: *Module, scope: *Scope, fntype: *zir.Inst.FnType) Inne | ... | @@ -760,7 +763,12 @@ fn analyzeInstFnType(mod: *Module, scope: *Scope, fntype: *zir.Inst.FnType) Inne |
| 760 | const arena = scope.arena(); | 763 | const arena = scope.arena(); |
| 761 | const param_types = try arena.alloc(Type, fntype.positionals.param_types.len); | 764 | const param_types = try arena.alloc(Type, fntype.positionals.param_types.len); |
| 762 | for (fntype.positionals.param_types) |param_type, i| { | 765 | for (fntype.positionals.param_types) |param_type, i| { |
| 763 | param_types[i] = try resolveType(mod, scope, param_type); | 766 | const resolved = try resolveType(mod, scope, param_type); |
| | 767 | // TODO skip for comptime params |
| | 768 | if (!resolved.isValidVarType()) { |
| | 769 | return mod.fail(scope, param_type.src, "parameter of type '{}' must be declared comptime", .{resolved}); |
| | 770 | } |
| | 771 | param_types[i] = resolved; |
| 764 | } | 772 | } |
| 765 | | 773 | |
| 766 | const payload = try arena.create(Type.Payload.Function); | 774 | const payload = try arena.create(Type.Payload.Function); |