Skip to content

Instantly share code, notes, and snippets.

Created February 23, 2018 08:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/527e90e07b203eacd0b63f6be2412507 to your computer and use it in GitHub Desktop.
Save anonymous/527e90e07b203eacd0b63f6be2412507 to your computer and use it in GitHub Desktop.
const Point = struct { value: u32 };
const TypeInfo = struct { t: type };
fn get_type_info(comptime T: type) (comptime TypeInfo)
{
return TypeInfo{ .t = T };
}
pub fn main() void
{
comptime const info_t = TypeInfo{ .t = Point }; // Works
comptime const info = get_type_info(Point); // error: cannot store runtime value in compile time variable
@compileLog(info);
const v = info.self_type { .value = 11 };
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment