From 3ccd4907fbcd04ecddffb618a4b14581fd080279 Mon Sep 17 00:00:00 2001 From: Veikka Tuominen Date: Sat, 8 Oct 2022 15:29:05 +0300 Subject: Sema: add error for capturing a runtime value outside of function scope Closes #13104 --- .../accessing_runtime_paramter_outside_function_scope.zig | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 test/cases/compile_errors/accessing_runtime_paramter_outside_function_scope.zig (limited to 'test/cases/compile_errors') diff --git a/test/cases/compile_errors/accessing_runtime_paramter_outside_function_scope.zig b/test/cases/compile_errors/accessing_runtime_paramter_outside_function_scope.zig new file mode 100644 index 0000000000..583b7128c7 --- /dev/null +++ b/test/cases/compile_errors/accessing_runtime_paramter_outside_function_scope.zig @@ -0,0 +1,12 @@ +export fn entry(y: u8) void { + const Thing = struct { + y: u8 = y, + }; + _ = @sizeOf(Thing); +} + +// error +// backend=stage2 +// target=native +// +// :3:17: error: 'y' not accessible outside function scope -- cgit v1.2.3