diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-11-14 12:23:40 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-11-14 12:23:40 -0500 |
| commit | 3666fbd9f9465ba2ae70b178106e5d9e3cea68ca (patch) | |
| tree | f4d999b0d91df263c30b2bf6dff6f6a57fe3ea9b /src | |
| parent | 14308db923d361d857bd768ca7d6cb1f512081a1 (diff) | |
| download | zig-3666fbd9f9465ba2ae70b178106e5d9e3cea68ca.tar.gz zig-3666fbd9f9465ba2ae70b178106e5d9e3cea68ca.zip | |
** and ++ operators force comptime on operands
closes #1707
Diffstat (limited to 'src')
| -rw-r--r-- | src/ir.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 0d1cbd04dd..128b53fc2d 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -3182,8 +3182,13 @@ static IrInstruction *ir_gen_block(IrBuilder *irb, Scope *parent_scope, AstNode } static IrInstruction *ir_gen_bin_op_id(IrBuilder *irb, Scope *scope, AstNode *node, IrBinOp op_id) { - IrInstruction *op1 = ir_gen_node(irb, node->data.bin_op_expr.op1, scope); - IrInstruction *op2 = ir_gen_node(irb, node->data.bin_op_expr.op2, scope); + Scope *inner_scope = scope; + if (op_id == IrBinOpArrayCat || op_id == IrBinOpArrayMult) { + inner_scope = create_comptime_scope(irb->codegen, node, scope); + } + + IrInstruction *op1 = ir_gen_node(irb, node->data.bin_op_expr.op1, inner_scope); + IrInstruction *op2 = ir_gen_node(irb, node->data.bin_op_expr.op2, inner_scope); if (op1 == irb->codegen->invalid_instruction || op2 == irb->codegen->invalid_instruction) return irb->codegen->invalid_instruction; |
