-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zig 0.14-master update fixes #27
Conversation
Update `@setCold(true)` to `@branchHint(.cold)` builtin function as per the migration made in ziglang/zig@6808ce27.
Commit ziglang/zig@0fe3fd0 from the Zig repository introduced breaking changes in their migration of the `Type` fields to follow naming conventions. Some blocks could not be successfully migrated and have been marked with 'TODO' comments.
// TODO: Re-enable comptime tests | ||
const comptime_tests_enabled = b.option(bool, "comptime-tests", "Run comptime tests") orelse false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the TODO!
I fear most of the comptime capabilities in mustache-zig are compromised due to recent changes in how Zig treats comptime memory (only const pointers are allowed to "leak" into runtime code). But let the language stabilize a bit more before trying to make this work again.
// TODO: Determine why Zig states this line is "access of inactive union field" | ||
//self.state = .{ .produce_close = close_state.part_type }; | ||
self.state = .{ .produce_close = close_state_copy.part_type }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I faced this same issue ... I guess it's a miscompilation. Nice workaround!
// TODO: Update types to oncemore be strict on the input type | ||
//const Type = std.builtin.Type; | ||
//const FnParam = Type.@"fn".Param; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you motivate why this TODO?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies, I should've explained that better. If I change the lines such that lines 141-146 read
// TODO: Update types to oncemore be strict on the input type
const Type = std.builtin.Type;
const FnParam = Type.@"fn".Param;
const paramIs = struct {
fn action(comptime param: FnParam, comptime types: []const type) bool {
Then upon running zig build test
I am met with a plethora of errors all stating
src/rendering/contexts/native/lambda.zig:143:31: error: type '@typeInfo(builtin.Type).@"union".tag_type.?' does not support field access
const FnParam = Type.@"fn".Param;
~~~~~~~~~~^~~~~~
zig/lib/std/builtin.zig:257:18: note: enum declared here
pub const Type = union(enum) {
^~~~~
src/rendering/contexts/native/invoker.zig:199:90: note: called from here
const is_valid_lambda = comptime lambda.isValidLambdaFunction(TValue, @TypeOf(bound_fn));
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
I was not sure how exactly to handle this and thus marked it as something to work on in the future. I'll be sure to be more clear about that next time and apologize for any confusion I may have caused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, in this case we don't need to change Fn
to @"fn"
, as we do need to access the type, not the union field.
See https://ziglang.org/documentation/master/std/#std.builtin.Type.Fn.Param
Can you send another PR fixing it?
I've applied the fixes that I currently could toward allowing the majority of the tests to run once more (see #26). Namely,
@setCold(true)
builtin to@branchHint(.cold)
Type
fields to use the new naming:.Pointer
.pointer
.Null
.null
.Enum
.@"enum"
I was unable to get some of the comptime tests to continue to work and have disabled comptime tests in the meantime. If you have any ideas of why the
expectComptimeRender
andexpectComptimeRenderPartials
fromsrc/rendering/rendering.zig
functions would throwerror: runtime value contains reference to comptime var
when usingzig build test
, please let me know.I also had to edit
src/rendering/contexts/native/lambda.zig
such thatisValidLambdaFunction
would no longer use thestd.builtin.Type.@"fn".Param
type due to receiving a error about there being invalid field access on a@"union"
. Each of these areas which I had issues with should be marked with "TODO" comments.Lastly, I understand that this is a large change and apologize for that in advance. If these changes are not something that you wish to do at this time that is fine with me and this PR can be closed. That being said, if there is anything else you need please let me know.