-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix field alignment kludge by implementing lazy values #3115
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
Merged
Conversation
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
This breaks behavior tests as well as compile error notes for generic function calls. However it introduces better circular dependency compile errors. The next step is to add Lazy Values to fix the regressions.
this case now works: ```zig const Node = struct { field: fn (*Node) *Node, }; ```
this case now works: ```zig const A = struct { b: B, }; const B = fn (A) void; ```
this case works now: ```zig const A = struct { b_list_pointer: *const []B, }; const B = struct { a_pointer: *const A, }; const b_list: []B = [_]B{}; const a = A{ .b_list_pointer = &b_list }; const obj = B{ .a_pointer = &a }; ```
this case works now: ```zig const Node = struct { node: ?*Node, }; ```
this case regressed and now fixed: ```zig const a: ?*i32 = undefined; const b: ?*f32 = @ptrCast(?*f32, a); ```
this case works now: ```zig const Expr = union(enum) { Literal: u8, Question: *Expr, }; ```
this case works now: ```zig const Foo = struct { field: @typeof(func).ReturnType, }; fn func(self: *Foo) void {} ```
this case works now: ```zig const Foo = struct { field: Bar(@Alignof(*Foo)), }; fn Bar(comptime alignment: u29) type { return struct { field: *align(alignment) Foo, }; } ```
...with optional unwrapping with var initialized to undefined
and add check for alignment specified on enum fields
This was referenced Aug 27, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an implementation of lazy values (#2174) which is required to fix many false positive circular dependency bugs, as well as field alignment bugs. It also implements ability to set alignment of struct and union fields (#1512). It also improves the error notes for "unable to evaluate constant expression" (#1732).
Checklist:
resolve_struct_type
that calculates field offsets needs to have the logic fromget_struct_type