diff options
| author | kristopher tate <kt@connectfree.co.jp> | 2018-07-28 17:35:50 +0900 |
|---|---|---|
| committer | kristopher tate <kt@connectfree.co.jp> | 2018-08-02 16:50:08 +0900 |
| commit | a8ea2360958354ba8310c7cea388351299e72e44 (patch) | |
| tree | b7e9144ce0c3522ee13bb86b4b5fc13fb4b0e97c /src | |
| parent | fcf53b31fc2899cba682c4c9a8cade40c6e0ab9e (diff) | |
| download | zig-a8ea2360958354ba8310c7cea388351299e72e44.tar.gz zig-a8ea2360958354ba8310c7cea388351299e72e44.zip | |
src/ir.cpp: don't allow `@handle()` outside of a function;
Tracking Issue #1296 ;
Diffstat (limited to 'src')
| -rw-r--r-- | src/ir.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 9712cb0bc2..966d8e9f33 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -4493,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 (!irb->exec->fn_entry) { + add_node_error(irb->codegen, node, buf_sprintf("@handle() called outside of function definition")); + return irb->codegen->invalid_instruction; + } if (!is_async) { add_node_error(irb->codegen, node, buf_sprintf("@handle() in non-async function")); return irb->codegen->invalid_instruction; |
