Created
July 10, 2019 13:00
-
-
Save kevinw/30d653ae23b835183dd9282a341f4856 to your computer and use it in GitHub Desktop.
comptime type registry zig
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
| var allComponentTypes: []type = undefined; | |
| fn addComponent(comptime T: type) void { | |
| allComponentTypes = allComponentTypes ++ [1]type{T}; | |
| } | |
| test "add component" { | |
| const Mover = struct { | |
| foo: bool, | |
| }; | |
| addComponent(Mover); | |
| } | |
| >zig test registry.zig | |
| registry.zig:4:25: error: unable to evaluate constant expression | |
| allComponentTypes = allComponentTypes ++ [1]type{T}; | |
| ^ | |
| registry.zig:12:17: note: called from here | |
| addComponent(Mover); | |
| ^ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment