Created
July 10, 2019 13:33
-
-
Save kevinw/3088dbf4ac849c0e42f9549f2387abf3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const Node = struct { | |
| t: type = bool, | |
| next: ?*Node = null, | |
| }; | |
| var registry: ?*Node = null; | |
| fn addComponent(comptime T: type) void { | |
| registry = Node{ .t = T, .next = registry }; | |
| } | |
| test "add component" { | |
| const Mover = struct { | |
| foo: bool, | |
| }; | |
| comptime addComponent(Mover); | |
| } | |
| // RESULT: | |
| // | |
| //registry.zig:9:38: error: cannot store runtime value in type '?*Node' | |
| // registry = Node{ .t = T, .next = registry }; | |
| // ^ | |
| //registry.zig:17:26: note: called from here | |
| // comptime addComponent(Mover); | |
| ^ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment