-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Makes the declaration slice resolve lazely when using @typeInfo
.
#4435
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
Conversation
b50852f
to
aa271db
Compare
@typeInfo
lazy.@typeInfo
.
f23a976
to
31c1f0a
Compare
This way all the declarations in a container won't be resolved untill the user actually uses the decls slice in the builtin TypeInfo union.
31c1f0a
to
d8961f4
Compare
https://github.com/ziglang/zig/pull/4435/files#diff-d03d33b1588c4f305b248019071b9546L1349-L1366 The test above was deleted, because now the correct compile error is given:
Maybe i should have kept it and changed it instead, that is the debatable thing here. Btw, i guess the windows CI doesn't have its day. |
out_val->special = ConstValSpecialLazy; | ||
out_val->type = get_slice_type(ira->codegen, ptr_type); | ||
|
||
LazyValueTypeInfoDecls *lazy_type_info_decls = heap::c_allocator.create<LazyValueTypeInfoDecls>(); |
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.
This makes 1 lazy value for the entire thing, which means that if you access one decl, it brings in everything. I think this would be better to make a lazy value for each decl.
Or maybe this is still good and it can be a multi-layered lazy thing, and in resolving LazyValueIdTypeInfoDecls it would create lazy values for each element.
I think this is related to #4495.
It's the end of a long 2 days for me, I'm going to come back to this tomorrow, and we'll get this merged 👍
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.
Yes, I did that intentionally, because it seemed easier to implement at that point. However, I can now try to make each element a lazy value, will do that tonight after work :)
One thing I'm wondering is, what should happen when the slice is used in a for loop. Should it then resolve every value in the range of the slice?
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 had another look today, and I think this is good to merge as-is. Nice work!
I'm merging locally in a branch to add a behavior test case.
This fixes issues #3893, #2584 etc.