-
Notifications
You must be signed in to change notification settings - Fork 113
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
Initialization problems with preferunits
for physical constants on Julia 1.8
#545
Comments
Now we have two sets of Physical constants accessible this way: Na,q,k etc. from Unitful (didn't see them before) N_A,e, k_B from PhysicalConstants.CODATA2018 The former are buggy under Julia 1.8, see PainterQubits/Unitful.jl#545 Also, this taps now into the deeper mechanisms of Unitful. Look like a rabbit hole...
May be also linked to JuliaLang/julia#45861 Checked: it is not in 1.8-rc3 but has been added to the 1.8 backports so we may expect it in one of the next rc's. Edit: in nighly f1991edd30 the problem persists. |
Update: the problem persists in 1.8.0-rc4 |
Now that I’ve looked at this, I’m surprised that it ever worked. The problem is here: Lines 304 to 307 in dc044ee
This is a generated function that depends on non-constant global state ( Unitful.promotion ), which is not allowed.
Unfortunately, just making this function not I see two possible solutions:
|
Wow this seems to be a tough one - thanks for consideration! |
We don't keep backedges to the generator, so if it's called from the generator then indeed nothing will be recompiled. |
|
Hi, I struggle with a subtle issue concerning the definition of physical constants in unitful.jl after preferunits has been set.
I set up a small package on https://github.com/j-fu/UTest.jl which can be dev'd for testing.
In the root directory it contains
utest.jl
which can be called either withor with
The correct output is
This is obtained on all older Julia versions, and on 1.8 (beta, rc3) with
--compile=min
On 1.8 (beta, rc3) and 1.9 (f1991edd30) without
--compile=min
one getsOne gets the correct result with optimized code if after modification, the
--compile=min
has been called first. The problem occurs only for physical constants, not for units. PhysicalConstants.jl behaves in the right way, though.I see three possibilities here:
preferunits
is called before loading the package. If this is the case, it needs to be documented. (in fact I struggled with this situation in more obvious situations, so I have an Idea what to write into a PR...)The text was updated successfully, but these errors were encountered: