From 02b8d881539a665212b4ce4c174329cfd503ab54 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 24 Nov 2021 14:57:13 -0700 Subject: [PATCH] stage2: add test coverage for `@embedFile` outside package path closes #6662 --- test/compile_errors.zig | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/compile_errors.zig b/test/compile_errors.zig index 1a3e81e176..6bf7057064 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -3,6 +3,18 @@ const builtin = @import("builtin"); const TestContext = @import("../src/test.zig").TestContext; pub fn addCases(ctx: *TestContext) !void { + { + var case = ctx.obj("stage2 compile errors", .{}); + + case.addError( + \\export fn a() usize { + \\ return @embedFile("/root/foo").len; + \\} + , &[_][]const u8{ + ":2:12: error: embed of file outside package path: '/root/foo'", + }); + } + ctx.objErrStage1("issue #9346: return outside of function scope", \\pub const empty = return 1; , &.{"tmp.zig:1:19: error: 'return' outside function scope"});