Skip to content

Instantly share code, notes, and snippets.

@kevinw
Created July 10, 2019 13:33
Show Gist options
  • Select an option

  • Save kevinw/3088dbf4ac849c0e42f9549f2387abf3 to your computer and use it in GitHub Desktop.

Select an option

Save kevinw/3088dbf4ac849c0e42f9549f2387abf3 to your computer and use it in GitHub Desktop.
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