-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Extend PartialStruct
to represent non-contiguously defined fields
#57304
Conversation
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.
Instead of a separate BitVector{Bool}
, would it be better to add a tombstone / marker for non-Const
fields (e.g. Any
)?
That seems easier to iterate and more memory-efficient for the common case of small structs.
The issue with choosing We could have a sentinel value like |
The sentinel for a value that definitely throws on access is Union{} and appears throughout inference for that purpose. If you are only tracking may-throw, then you need something like our VarInfo to add a boolean for it, but that complicates the type lattice |
I think @serenity4 wants the opposite here - something that definitely doesn't throw on access. The pattern to copy is probably That makes this two separate enhancements: (1) handling non-contiguous fields, and (2) tracking type / defined-ness independently - seems fair to me |
We need a very basic "may-throw" information here, which in the current state is encoded as a lack of information. The idea was to avoid complicating the type lattice, which is why I went for a solution that does not require introducing a new sentinel value, and instead keeps track externally of available information. But on the other hand, it makes little sense to iterate this |
Note that (2) is already implemented in current |
Is it possible to represent on current |
No, |
Hmm, it feels strange that you can represent a My vote would be to either go in the VarState direction and make definedness independent from the type information, or else keep PartialStruct's existing limitations for |
In what situation would you want to model In the current state (
The only thing it doesn't model is certainty that a field is undefined, but I don't find any situation where this would be particularly useful. (plus, as we can't unset fields, it would be hard to make this guarantee in the first place, unless it is immutable or all operations on the object are known since its creation) |
You should read this as "maybe-undefined and Const when it is defined" because the That is what |
Ah I see, indeed we have been conservative with In fact, it is already possible to do so using conditional branching information with My understanding is that since I'd suggest to keep relying on the same mechanisms to express that, and perhaps use |
The
So, right now, the Though since field defined-ness is really similar variable defined-ness information represented by Regardless of which approach we take, we'll need to carefully audit all the places where |
VarState's
I think that's the main point of discussion - the current data structure can't represent those two pieces of information separately, since That said, I'm a fan of @serenity4's plan above to leave that enhancement for later - it seems likely to impact a lot more code vs. the smaller changeset here |
I'm a bit confused about this. Are you saying we can't represent a struct PartialStruct
typ
fields::Vector{Any}
maybeundef::BitVector
end
x = PartialStruct(Base.RefValue{Any}, Any[Const(42)], trues(1)) We'd need to handle the "maybe undef" information correctly everywhere we access |
We would essentialy go with a vectorized version of
The main difference with the current state of this PR (besides In this way, we move out the information that the |
If we are worried about memory efficiency/performance (notably for large structs), we can always keep the optimization that if there exists That seems to be the cost of being able to express both |
This description sounds concerning, as it seems to mean we cannot correctly represent the tmerge of two of these such types |
We can't simply |
8a9f31d
to
67b9168
Compare
Oh, I see, that is slightly confusing, since it goes the opposite direction of the lattice normally is implemented, and so it discards information slightly faster than expected. This change to the bitvector approach (with an optimization that it only gets allocated if any are maybe-undefined) seems slightly clearer semantically. |
@nanosoldier |
@nanosoldier |
Your benchmark job has completed - no performance regressions were detected. A full report can be found here. |
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.
lgtm
748960c
to
02365ae
Compare
Since this PR got merged, we are experiencing a lot of errors in our nightly CI at Oscar.jl, see e.g. https://github.com/oscar-system/Oscar.jl/actions/runs/13512859928/job/37756278557#step:11:714 From worker 4: Internal error: during type inference of
From worker 4: degeneracy_locus(Oscar.IntersectionTheory.AbstractBundle{Oscar.IntersectionTheory.AbstractVariety}, Oscar.IntersectionTheory.AbstractBundle{Oscar.IntersectionTheory.AbstractVariety}, Int64)
From worker 4: Encountered unexpected error in runtime:
From worker 4: MethodError(f=Base.string, args=(Expr(:call, :!==, Expr(:ref, :fields, :i), Expr(:curly, :Union)),), world=0x0000000000002f2a)
From worker 4: jl_method_error_bare at /cache/build/builder-amdci5-1/julialang/julia-master/src/gf.c:2508
From worker 4: jl_method_error at /cache/build/builder-amdci5-1/julialang/julia-master/src/gf.c:2526
From worker 4: jl_f_throw_methoderror at /cache/build/builder-amdci5-1/julialang/julia-master/src/builtins.c:587 [inlined]
From worker 4: jl_f_throw_methoderror at /cache/build/builder-amdci5-1/julialang/julia-master/src/builtins.c:583
From worker 4: _assert_tostring at ./error.jl:249
From worker 4: unknown function (ip: 0x7f7093d3bce2) at (unknown file)
From worker 4: PartialStruct at ./coreir.jl:43
From worker 4: jfptr_PartialStruct_136901.1 at /home/oscarci-tester/oscar-runners/runner-12/_work/_tool/julia/nightly/x64/lib/julia/sys.so (unknown line)
From worker 4: PartialStruct at ./../usr/share/julia/Compiler/src/typelattice.jl:768
From worker 4: form_partially_defined_struct at ./../usr/share/julia/Compiler/src/abstractinterpretation.jl:2157
From worker 4: abstract_call_builtin at ./../usr/share/julia/Compiler/src/abstractinterpretation.jl:2124
From worker 4: abstract_call_known at ./../usr/share/julia/Compiler/src/abstractinterpretation.jl:2648
From worker 4: abstract_call at ./../usr/share/julia/Compiler/src/abstractinterpretation.jl:2866
From worker 4: abstract_call at ./../usr/share/julia/Compiler/src/abstractinterpretation.jl:2859 [inlined]
From worker 4: abstract_call at ./../usr/share/julia/Compiler/src/abstractinterpretation.jl:3019
From worker 4: abstract_eval_call at ./../usr/share/julia/Compiler/src/abstractinterpretation.jl:3037 [inlined]
From worker 4: abstract_eval_statement_expr at ./../usr/share/julia/Compiler/src/abstractinterpretation.jl:3344
From worker 4: typeinf_local at ./../usr/share/julia/Compiler/src/abstractinterpretation.jl:4095
From worker 4: jfptr_typeinf_local_132155.1 at /home/oscarci-tester/oscar-runners/runner-12/_work/_tool/julia/nightly/x64/lib/julia/sys.so (unknown line)
From worker 4: typeinf at ./../usr/share/julia/Compiler/src/abstractinterpretation.jl:4287
From worker 4: typeinf_ext at ./../usr/share/julia/Compiler/src/typeinfer.jl:1169
From worker 4: typeinf_ext_toplevel at ./../usr/share/julia/Compiler/src/typeinfer.jl:1281 [inlined]
From worker 4: typeinf_ext_toplevel at ./../usr/share/julia/Compiler/src/typeinfer.jl:1289
From worker 4: jfptr_typeinf_ext_toplevel_131957.1 at /home/oscarci-tester/oscar-runners/runner-12/_work/_tool/julia/nightly/x64/lib/julia/sys.so (unknown line)
From worker 4: jl_apply at /cache/build/builder-amdci5-1/julialang/julia-master/src/julia.h:2284 [inlined]
From worker 4: jl_type_infer at /cache/build/builder-amdci5-1/julialang/julia-master/src/gf.c:453
From worker 4: jl_compile_method_internal at /cache/build/builder-amdci5-1/julialang/julia-master/src/gf.c:2972
From worker 4: _jl_invoke at /cache/build/builder-amdci5-1/julialang/julia-master/src/gf.c:3467 [inlined]
From worker 4: ijl_apply_generic at /cache/build/builder-amdci5-1/julialang/julia-master/src/gf.c:3675
From worker 4: jl_apply at /cache/build/builder-amdci5-1/julialang/julia-master/src/julia.h:2284 [inlined]
From worker 4: do_call at /cache/build/builder-amdci5-1/julialang/julia-master/src/interpreter.c:124
From worker 4: eval_value at /cache/build/builder-amdci5-1/julialang/julia-master/src/interpreter.c:242
From worker 4: eval_body at /cache/build/builder-amdci5-1/julialang/julia-master/src/interpreter.c:580
From worker 4: eval_body at /cache/build/builder-amdci5-1/julialang/julia-master/src/interpreter.c:557
From worker 4: eval_body at /cache/build/builder-amdci5-1/julialang/julia-master/src/interpreter.c:557
From worker 4: jl_interpret_toplevel_thunk at /cache/build/builder-amdci5-1/julialang/julia-master/src/interpreter.c:897
From worker 4: macro expansion at /home/oscarci-tester/oscar-runners/runner-12/_work/Oscar.jl/Oscar.jl/experimental/IntersectionTheory/test/runtests.jl:34 [inlined]
From worker 4: macro expansion at /home/oscarci-tester/oscar-runners/runner-12/_work/_tool/julia/nightly/x64/share/julia/stdlib/v1.13/Test/src/Test.jl:1771 [inlined]
From worker 4: top-level scope at /home/oscarci-tester/oscar-runners/runner-12/_work/Oscar.jl/Oscar.jl/experimental/IntersectionTheory/test/runtests.jl:31
From worker 4: jl_toplevel_eval_flex at /cache/build/builder-amdci5-1/julialang/julia-master/src/toplevel.c:1032
From worker 4: jl_toplevel_eval_flex at /cache/build/builder-amdci5-1/julialang/julia-master/src/toplevel.c:972
From worker 4: ijl_toplevel_eval at /cache/build/builder-amdci5-1/julialang/julia-master/src/toplevel.c:1044
From worker 4: ijl_toplevel_eval_in at /cache/build/builder-amdci5-1/julialang/julia-master/src/toplevel.c:1089
From worker 4: eval at ./boot.jl:488
From worker 4: include_string at ./loading.jl:2855
From worker 4: _include at ./loading.jl:2915
From worker 4: include at ./Base.jl:308
From worker 4: macro expansion at ./timing.jl:621 [inlined]
From worker 4: #_timed_include#45 at /home/oscarci-tester/oscar-runners/runner-12/_work/Oscar.jl/Oscar.jl/src/utils/tests.jl:5
From worker 4: _timed_include at /home/oscarci-tester/oscar-runners/runner-12/_work/Oscar.jl/Oscar.jl/src/utils/tests.jl:1 [inlined]
From worker 4: _timed_include at /home/oscarci-tester/oscar-runners/runner-12/_work/Oscar.jl/Oscar.jl/src/utils/tests.jl:1 [inlined]
From worker 4: #55 at /home/oscarci-tester/oscar-runners/runner-12/_work/Oscar.jl/Oscar.jl/src/utils/tests.jl:258
From worker 4: with_unicode at /home/oscarci-tester/oscar-runners/runner-12/julia/packages/AbstractAlgebra/lYBCD/src/PrettyPrinting.jl:1846
From worker 4: #test_module#53 at /home/oscarci-tester/oscar-runners/runner-12/_work/Oscar.jl/Oscar.jl/src/utils/tests.jl:206 [inlined]
From worker 4: test_module at /home/oscarci-tester/oscar-runners/runner-12/_work/Oscar.jl/Oscar.jl/src/utils/tests.jl:205 [inlined]
From worker 4: #21 at ./none (unknown line) [inlined]
From worker 4: #exec_from_cache#148 at /home/oscarci-tester/oscar-runners/runner-12/_work/_tool/julia/nightly/x64/share/julia/stdlib/v1.13/Distributed/src/workerpool.jl:390
From worker 4: exec_from_cache at /home/oscarci-tester/oscar-runners/runner-12/_work/_tool/julia/nightly/x64/share/julia/stdlib/v1.13/Distributed/src/workerpool.jl:388
From worker 4: unknown function (ip: 0x7f70c0129d96) at (unknown file)
From worker 4: jl_apply at /cache/build/builder-amdci5-1/julialang/julia-master/src/julia.h:2284 [inlined]
From worker 4: jl_f__call_latest at /cache/build/builder-amdci5-1/julialang/julia-master/src/builtins.c:883
From worker 4: jl_apply at /cache/build/builder-amdci5-1/julialang/julia-master/src/julia.h:2284 [inlined]
From worker 4: do_apply at /cache/build/builder-amdci5-1/julialang/julia-master/src/builtins.c:839
From worker 4: #invokelatest#1 at ./essentials.jl:1090
From worker 4: jl_apply at /cache/build/builder-amdci5-1/julialang/julia-master/src/julia.h:2284 [inlined]
From worker 4: do_apply at /cache/build/builder-amdci5-1/julialang/julia-master/src/builtins.c:839
From worker 4: invokelatest at ./essentials.jl:1086
From worker 4: jl_apply at /cache/build/builder-amdci5-1/julialang/julia-master/src/julia.h:2284 [inlined]
From worker 4: do_apply at /cache/build/builder-amdci5-1/julialang/julia-master/src/builtins.c:839
From worker 4: #handle_msg##4 at /home/oscarci-tester/oscar-runners/runner-12/_work/_tool/julia/nightly/x64/share/julia/stdlib/v1.13/Distributed/src/process_messages.jl:287
From worker 4: run_work_thunk at /home/oscarci-tester/oscar-runners/runner-12/_work/_tool/julia/nightly/x64/share/julia/stdlib/v1.13/Distributed/src/process_messages.jl:70
From worker 4: #handle_msg##2 at /home/oscarci-tester/oscar-runners/runner-12/_work/_tool/julia/nightly/x64/share/julia/stdlib/v1.13/Distributed/src/process_messages.jl:287
From worker 4: unknown function (ip: 0x7f70c0121987) at (unknown file)
From worker 4: jl_apply at /cache/build/builder-amdci5-1/julialang/julia-master/src/julia.h:2284 [inlined]
From worker 4: start_task at /cache/build/builder-amdci5-1/julialang/julia-master/src/task.c:1249
From worker 4: Internal error: during type inference of
From worker 4: abstract_projective_bundle(Oscar.IntersectionTheory.AbstractBundle{Oscar.IntersectionTheory.AbstractVariety})
From worker 4: Encountered unexpected error in runtime:
From worker 4: MethodError(f=Base.string, args=(Expr(:call, :!==, Expr(:ref, :fields, :i), Expr(:curly, :Union)),), world=0x0000000000002f2a)
From worker 4: jl_method_error_bare at /cache/build/builder-amdci5-1/julialang/julia-master/src/gf.c:2508
From worker 4: jl_method_error at /cache/build/builder-amdci5-1/julialang/julia-master/src/gf.c:2526
From worker 4: jl_f_throw_methoderror at /cache/build/builder-amdci5-1/julialang/julia-master/src/builtins.c:587 [inlined]
From worker 4: jl_f_throw_methoderror at /cache/build/builder-amdci5-1/julialang/julia-master/src/builtins.c:583
From worker 4: _assert_tostring at ./error.jl:249
From worker 4: unknown function (ip: 0x7f7093d3bce2) at (unknown file)
From worker 4: PartialStruct at ./coreir.jl:43
From worker 4: jfptr_PartialStruct_136901.1 at /home/oscarci-tester/oscar-runners/runner-12/_work/_tool/julia/nightly/x64/lib/julia/sys.so (unknown line)
From worker 4: PartialStruct at ./../usr/share/julia/Compiler/src/typelattice.jl:[768](https://github.com/oscar-system/Oscar.jl/actions/runs/13512859928/job/37756278557#step:11:771)
From worker 4: form_partially_defined_struct at ./../usr/share/julia/Compiler/src/abstractinterpretation.jl:2157
From worker 4: abstract_call_builtin at ./../usr/share/julia/Compiler/src/abstractinterpretation.jl:2124
From worker 4: abstract_call_known at ./../usr/share/julia/Compiler/src/abstractinterpretation.jl:2648
From worker 4: abstract_call at ./../usr/share/julia/Compiler/src/abstractinterpretation.jl:2866
From worker 4: abstract_call at ./../usr/share/julia/Compiler/src/abstractinterpretation.jl:2859 [inlined]
From worker 4: abstract_call at ./../usr/share/julia/Compiler/src/abstractinterpretation.jl:3019
From worker 4: abstract_eval_call at ./../usr/share/julia/Compiler/src/abstractinterpretation.jl:3037 [inlined]
From worker 4: abstract_eval_statement_expr at ./../usr/share/julia/Compiler/src/abstractinterpretation.jl:3344
From worker 4: typeinf_local at ./../usr/share/julia/Compiler/src/abstractinterpretation.jl:4095
From worker 4: jfptr_typeinf_local_132155.1 at /home/oscarci-tester/oscar-runners/runner-12/_work/_tool/julia/nightly/x64/lib/julia/sys.so (unknown line)
From worker 4: typeinf at ./../usr/share/julia/Compiler/src/abstractinterpretation.jl:4287
From worker 4: typeinf_ext at ./../usr/share/julia/Compiler/src/typeinfer.jl:1169
From worker 4: typeinf_ext_toplevel at ./../usr/share/julia/Compiler/src/typeinfer.jl:1281 [inlined]
From worker 4: typeinf_ext_toplevel at ./../usr/share/julia/Compiler/src/typeinfer.jl:1289
From worker 4: jfptr_typeinf_ext_toplevel_131957.1 at /home/oscarci-tester/oscar-runners/runner-12/_work/_tool/julia/nightly/x64/lib/julia/sys.so (unknown line)
From worker 4: jl_apply at /cache/build/builder-amdci5-1/julialang/julia-master/src/julia.h:2284 [inlined]
From worker 4: jl_type_infer at /cache/build/builder-amdci5-1/julialang/julia-master/src/gf.c:453
From worker 4: jl_compile_method_internal at /cache/build/builder-amdci5-1/julialang/julia-master/src/gf.c:2972
From worker 4: _jl_invoke at /cache/build/builder-amdci5-1/julialang/julia-master/src/gf.c:3467 [inlined]
From worker 4: ijl_apply_generic at /cache/build/builder-amdci5-1/julialang/julia-master/src/gf.c:3675
From worker 4: #degeneracy_locus#143 at /home/oscarci-tester/oscar-runners/runner-12/_work/Oscar.jl/Oscar.jl/experimental/IntersectionTheory/src/Main.jl:2172
From worker 4: unknown function (ip: 0x7f7093d3de4c) at (unknown file)
From worker 4: degeneracy_locus at /home/oscarci-tester/oscar-runners/runner-12/_work/Oscar.jl/Oscar.jl/experimental/IntersectionTheory/src/Main.jl:2160
From worker 4: unknown function (ip: 0x7f7093d3be20) at (unknown file)
From worker 4: jl_apply at /cache/build/builder-amdci5-1/julialang/julia-master/src/julia.h:2284 [inlined]
From worker 4: do_call at /cache/build/builder-amdci5-1/julialang/julia-master/src/interpreter.c:124
From worker 4: eval_value at /cache/build/builder-amdci5-1/julialang/julia-master/src/interpreter.c:242
From worker 4: eval_body at /cache/build/builder-amdci5-1/julialang/julia-master/src/interpreter.c:580
From worker 4: eval_body at /cache/build/builder-amdci5-1/julialang/julia-master/src/interpreter.c:557
From worker 4: eval_body at /cache/build/builder-amdci5-1/julialang/julia-master/src/interpreter.c:557
From worker 4: jl_interpret_toplevel_thunk at /cache/build/builder-amdci5-1/julialang/julia-master/src/interpreter.c:897
From worker 4: macro expansion at /home/oscarci-tester/oscar-runners/runner-12/_work/Oscar.jl/Oscar.jl/experimental/IntersectionTheory/test/runtests.jl:34 [inlined]
From worker 4: macro expansion at /home/oscarci-tester/oscar-runners/runner-12/_work/_tool/julia/nightly/x64/share/julia/stdlib/v1.13/Test/src/Test.jl:1[771](https://github.com/oscar-system/Oscar.jl/actions/runs/13512859928/job/37756278557#step:11:774) [inlined]
From worker 4: top-level scope at /home/oscarci-tester/oscar-runners/runner-12/_work/Oscar.jl/Oscar.jl/experimental/IntersectionTheory/test/runtests.jl:31
From worker 4: jl_toplevel_eval_flex at /cache/build/builder-amdci5-1/julialang/julia-master/src/toplevel.c:1032
From worker 4: jl_toplevel_eval_flex at /cache/build/builder-amdci5-1/julialang/julia-master/src/toplevel.c:972
From worker 4: ijl_toplevel_eval at /cache/build/builder-amdci5-1/julialang/julia-master/src/toplevel.c:1044
From worker 4: ijl_toplevel_eval_in at /cache/build/builder-amdci5-1/julialang/julia-master/src/toplevel.c:1089
From worker 4: eval at ./boot.jl:488
From worker 4: include_string at ./loading.jl:2855
From worker 4: _include at ./loading.jl:2915
From worker 4: include at ./Base.jl:308
From worker 4: macro expansion at ./timing.jl:621 [inlined]
From worker 4: #_timed_include#45 at /home/oscarci-tester/oscar-runners/runner-12/_work/Oscar.jl/Oscar.jl/src/utils/tests.jl:5
From worker 4: _timed_include at /home/oscarci-tester/oscar-runners/runner-12/_work/Oscar.jl/Oscar.jl/src/utils/tests.jl:1 [inlined]
From worker 4: _timed_include at /home/oscarci-tester/oscar-runners/runner-12/_work/Oscar.jl/Oscar.jl/src/utils/tests.jl:1 [inlined]
From worker 4: #55 at /home/oscarci-tester/oscar-runners/runner-12/_work/Oscar.jl/Oscar.jl/src/utils/tests.jl:258
From worker 4: with_unicode at /home/oscarci-tester/oscar-runners/runner-12/julia/packages/AbstractAlgebra/lYBCD/src/PrettyPrinting.jl:1846
From worker 4: #test_module#53 at /home/oscarci-tester/oscar-runners/runner-12/_work/Oscar.jl/Oscar.jl/src/utils/tests.jl:206 [inlined]
From worker 4: test_module at /home/oscarci-tester/oscar-runners/runner-12/_work/Oscar.jl/Oscar.jl/src/utils/tests.jl:205 [inlined]
From worker 4: #21 at ./none (unknown line) [inlined]
From worker 4: #exec_from_cache#148 at /home/oscarci-tester/oscar-runners/runner-12/_work/_tool/julia/nightly/x64/share/julia/stdlib/v1.13/Distributed/src/workerpool.jl:390
From worker 4: exec_from_cache at /home/oscarci-tester/oscar-runners/runner-12/_work/_tool/julia/nightly/x64/share/julia/stdlib/v1.13/Distributed/src/workerpool.jl:388
From worker 4: unknown function (ip: 0x7f70c0129d96) at (unknown file)
From worker 4: jl_apply at /cache/build/builder-amdci5-1/julialang/julia-master/src/julia.h:2284 [inlined]
From worker 4: jl_f__call_latest at /cache/build/builder-amdci5-1/julialang/julia-master/src/builtins.c:883
From worker 4: jl_apply at /cache/build/builder-amdci5-1/julialang/julia-master/src/julia.h:2284 [inlined]
From worker 4: do_apply at /cache/build/builder-amdci5-1/julialang/julia-master/src/builtins.c:839
From worker 4: #invokelatest#1 at ./essentials.jl:1090
From worker 4: jl_apply at /cache/build/builder-amdci5-1/julialang/julia-master/src/julia.h:2284 [inlined]
From worker 4: do_apply at /cache/build/builder-amdci5-1/julialang/julia-master/src/builtins.c:839
From worker 4: invokelatest at ./essentials.jl:1086
From worker 4: jl_apply at /cache/build/builder-amdci5-1/julialang/julia-master/src/julia.h:2284 [inlined]
From worker 4: do_apply at /cache/build/builder-amdci5-1/julialang/julia-master/src/builtins.c:839
From worker 4: #handle_msg##4 at /home/oscarci-tester/oscar-runners/runner-12/_work/_tool/julia/nightly/x64/share/julia/stdlib/v1.13/Distributed/src/process_messages.jl:287
From worker 4: run_work_thunk at /home/oscarci-tester/oscar-runners/runner-12/_work/_tool/julia/nightly/x64/share/julia/stdlib/v1.13/Distributed/src/process_messages.jl:70
From worker 4: #handle_msg##2 at /home/oscarci-tester/oscar-runners/runner-12/_work/_tool/julia/nightly/x64/share/julia/stdlib/v1.13/Distributed/src/process_messages.jl:287
From worker 4: unknown function (ip: 0x7f70c0121987) at (unknown file)
From worker 4: jl_apply at /cache/build/builder-amdci5-1/julialang/julia-master/src/julia.h:2284 [inlined]
From worker 4: start_task at /cache/build/builder-amdci5-1/julialang/julia-master/src/task.c:1249 This goes on for another ~4000 lines in the above mentioned log. cc @benlorenz |
It is hitting this assertion: Lines 42 to 44 in 9f7cdfd
By any chance, do you have any structs (whether by parametrization or hardcoded) that hold In any case, perhaps we might want to add proper support for |
We can hit the assertion with structs like: julia> mutable struct XY{X,Y}
x::X
y::Y
XY(x::X) where X = new{X,Union{}}(x)
XY(x::X,y::Y) where {X,Y} = new{X,Y}(x,y)
end
julia> XY(1)
XY{Int64, Union{}}(1, #undef)
julia> fieldtype(typeof(XY(1)), 1)
Int64
julia> fieldtype(typeof(XY(1)), 2)
Union{} |
Yeah, we would probably need to add a proper support for |
OK, so is that something that can be done quickly? Otherwise perhaps this should be reverted for now? |
@serenity4 Do you have any availability to work on this promptly? Otherwise I'll take care of it. |
I can work on it starting tomorrow, today I'll be travelling. Feel free to do the fix in the meantime if you prefer to get it done sooner :) |
ok, I submitted #57541 |
So far,
PartialStruct
has been unable to represent non-contiguously defined fields, where e.g. a struct would have fields 1 and 3 defined but not field 2. This PR extends it so that such information may be represented withPartialStruct
, extending the applicability of optimizations e.g. introduced in #55297 by @aviatesk or #57222.The semantics of
new
prevent the creation of a struct with non-contiguously defined fields, therefore this change is mostly relevant to model mutable structs whose fields may be previously set or assumed to be defined after creation, or immutable structs whose creation is opaque.Notably, with this change we may now infer information about structs in the following case:
whereas previously, only information gained successively with
isdefined(mut, :x) && isdefined(mut, :y) && isdefined(mut, :z)
could allow inference to modelmut
having itsz
field defined.