Skip to content
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

World age errors with --compiled-modules=no #232

Closed
c42f opened this issue May 17, 2019 · 2 comments
Closed

World age errors with --compiled-modules=no #232

c42f opened this issue May 17, 2019 · 2 comments

Comments

@c42f
Copy link
Contributor

c42f commented May 17, 2019

Various of the Unitful tests are broken when using julia --compiled-modules=no, due to the definition order of functions and methods relative to generated functions. For example

Construction: Error During Test at /home/tcfoster/.julia/dev/Unitful/test/runtests.jl:57
  Test threw exception
  Expression: 3 * (ContextUnits(m) / ContextUnits(m)) === 3
  MethodError: no method matching ^(::Unitful.Unit{:Meter,𝐋}, ::Rational{Int64})
  The applicable method may be too new: running in world age 25620, while current world is 26541.
  Closest candidates are:
    ^(::Unitful.Unit{U,D}, ::Number) where {U, D} at /home/tcfoster/.julia/dev/Unitful/src/units.jl:105 (method too new to be called from this world context.)
    ^(!Matched::Missing, ::Number) at missing.jl:97
    ^(!Matched::Irrational{:ℯ}, ::Rational) at mathconstants.jl:91
    ...
  Stacktrace:
   [1] (::getfield(Unitful, Symbol("##4#5")))(::Unitful.Dimension{:Length}) at ./array.jl:0
   [2] iterate(::Base.Generator{Tuple{Unitful.Dimension{:Length}},getfield(Unitful, Symbol("##4#5"))}) at ./generator.jl:47
   [3] append_any(::Any, ::Vararg{Any,N} where N) at ./essentials.jl:674
   [4] #s5#3(::Any, ::Any, ::Any) at /home/tcfoster/.julia/dev/Unitful/src/user.jl:306
   [5] (::Core.GeneratedFunctionStub)(::Any, ::Vararg{Any,N} where N) at ./boot.jl:522
   [6] upreferred at /home/tcfoster/.julia/dev/Unitful/src/user.jl:329 [inlined]
   [7] Unitful.ContextUnits(::Unitful.FreeUnits{(m,),𝐋,nothing}) at /home/tcfoster/.julia/dev/Unitful/src/types.jl:107
   [8] top-level scope at /home/tcfoster/.julia/dev/Unitful/test/runtests.jl:57
   [9] top-level scope at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.1/Test/src/Test.jl:1083
   [10] top-level scope at /home/tcfoster/.julia/dev/Unitful/test/runtests.jl:38

This seems to be the same root cause as #231 (ie, methods not defined at the time of generated function definition) but the fix is arguably a bit different as it requires changing the order of how functions are defined within Unitful itself.

I tried doing this, but I got confused by the interdependence between upreferred(:: and unary *(::FreeUnits). The backtraces seemed misleading.

@ajkeller34
Copy link
Collaborator

This is probably the next issue I'll tackle. I can get most of the tests to pass already but there are some subtle bugs that can give incorrect results without throwing MethodErrors.

ajkeller34 pushed a commit to rigetti/Unitful.jl that referenced this issue Jun 14, 2019
ajkeller34 added a commit that referenced this issue Jun 14, 2019
@ajkeller34
Copy link
Collaborator

Fixed by #243

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants