aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/basic.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-08-01 12:27:22 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-08-01 12:36:04 -0700
commit6ae0825e7f87fc9b73a4b968964196b0e164f062 (patch)
tree9c48fd4314fda457e5c54717407f0b15ea3aff8e /test/behavior/basic.zig
parent7e52a096dbace546cae89ab691741ecca45f28ce (diff)
downloadzig-6ae0825e7f87fc9b73a4b968964196b0e164f062.tar.gz
zig-6ae0825e7f87fc9b73a4b968964196b0e164f062.zip
Sema: implement comptime variables
Sema now properly handles alloc_inferred and alloc_inferred_mut ZIR instructions inside a comptime execution context. In this case it creates Decl objects and points to them with the new `decl_ref_mut` Value Tag. `storePtr` is updated to mutate such Decl types and values. In this case it destroys the old arena and makes a new one, preventing memory growth during comptime code execution. Additionally: * Fix `storePtr` to emit a compile error for a pointer comptime-known to be undefined. * Fix `storePtr` to emit runtime instructions for all the cases that a pointer is comptime-known but does not support comptime dereferencing, such as `@intToPtr` on a hard-coded address, or an extern function. * Fix `ret_coerce` not coercing inside inline function call context.
Diffstat (limited to 'test/behavior/basic.zig')
-rw-r--r--test/behavior/basic.zig9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/behavior/basic.zig b/test/behavior/basic.zig
new file mode 100644
index 0000000000..8f0f20cdf5
--- /dev/null
+++ b/test/behavior/basic.zig
@@ -0,0 +1,9 @@
+// normal comment
+
+/// this is a documentation comment
+/// doc comment line 2
+fn emptyFunctionWithComments() void {}
+
+test "empty function with comments" {
+ emptyFunctionWithComments();
+}