aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorkristopher tate <kt@connectfree.co.jp>2018-07-28 15:23:09 +0900
committerkristopher tate <kt@connectfree.co.jp>2018-08-02 16:50:08 +0900
commitc1a3b0cb0af3c0639ce09b2a17a3cc90977346fe (patch)
tree14e5dafe980129865632a0f411acb93187b984b8 /src/ir.cpp
parentdb362bec185d2eeb5a4dd018deb2a988479f0f1a (diff)
downloadzig-c1a3b0cb0af3c0639ce09b2a17a3cc90977346fe.tar.gz
zig-c1a3b0cb0af3c0639ce09b2a17a3cc90977346fe.zip
src/ir.cpp: add/throw error for @handle() in a non async context;
Tracking Issue #1296 ; Thanks @andrewrk ;
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index 50c8c70290..1e9d1bdb7e 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -3858,6 +3858,8 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo
return irb->codegen->invalid_instruction;
}
+ bool is_async = exec_is_async(irb->exec);
+
switch (builtin_fn->id) {
case BuiltinFnIdInvalid:
zig_unreachable();
@@ -4491,6 +4493,10 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo
case BuiltinFnIdFrameAddress:
return ir_lval_wrap(irb, scope, ir_build_frame_address(irb, scope, node), lval);
case BuiltinFnIdHandle:
+ if (!is_async) {
+ add_node_error(irb->codegen, node, buf_sprintf("@handle() in non-async function"));
+ return irb->codegen->invalid_instruction;
+ }
return ir_lval_wrap(irb, scope, ir_build_handle(irb, scope, node), lval);
case BuiltinFnIdAlignOf:
{