From 3666fbd9f9465ba2ae70b178106e5d9e3cea68ca Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 14 Nov 2018 12:23:40 -0500 Subject: ** and ++ operators force comptime on operands closes #1707 --- src/ir.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/ir.cpp') 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; -- cgit v1.2.3