SHARE
TWEET

Untitled

a guest Jul 21st, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var allComponentTypes: []type = undefined;
  2.  
  3. fn addComponent(comptime T: type) void {
  4.     allComponentTypes = allComponentTypes ++ [1]type{T};
  5. }
  6.  
  7. test "add component" {
  8.     const Mover = struct {
  9.         foo: bool,
  10.     };
  11.  
  12.     addComponent(Mover);
  13. }
  14.  
  15. >zig test registry.zig
  16. registry.zig:4:25: error: unable to evaluate constant expression
  17.     allComponentTypes = allComponentTypes ++ [1]type{T};
  18.                         ^
  19. registry.zig:12:17: note: called from here
  20.     addComponent(Mover);
  21.                 ^
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top