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

Don't use type-printing from inside a generated function #466

Merged
merged 1 commit into from
Feb 11, 2024

Conversation

Keno
Copy link

@Keno Keno commented Feb 10, 2024

Base's type printing code uses the REPL's currently active module to determine how to print types. Unfortunately, this means it is illegal to use this in generated functions. Switch to grabbing the symbol directly from the typename, since this now errors on julia master:

  Got exception outside of a @test
  LoadError: MethodError: no method matching active_module()
  You may have intended to import Base.active_module
  The applicable method may be too new: running in world age 26446, while current world is 26576.

  Closest candidates are:
    active_module(::REPL.LineEditREPL) (method too new to be called from this world context.)
     @ REPL ~/julia/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:590
    active_module() (method too new to be called from this world context.)
     @ REPL ~/julia/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:586
    active_module(::REPL.REPLDisplay) (method too new to be called from this world context.)
     @ REPL ~/julia/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:592
    ...

  Stacktrace:
    [1] #invokelatest#2
      @ ./essentials.jl:1025 [inlined]
    [2] invokelatest
      @ ./essentials.jl:1022 [inlined]
    [3] active_module
      @ ./show.jl:512 [inlined]
    [4] show_type_name(io::IOBuffer, tn::Core.TypeName)
      @ Base ./show.jl:1051
    [5] _show_type(io::IOBuffer, x::Type)
      @ Base ./show.jl:966
    [6] show(io::IOBuffer, x::Type)
      @ Base ./show.jl:963
    [7] print(io::IOBuffer, x::Type)
      @ Base ./strings/io.jl:35
    [8] print_to_string(xs::Type)
      @ Base ./strings/io.jl:148
    [9] string
      @ ./strings/io.jl:189 [inlined]
   [10] defaultalg_symbol(::Type{LinearSolve.LUFactorization{LinearAlgebra.RowMaximum}})
      @ LinearSolve ~/.julia/packages/LinearSolve/4aydZ/src/default.jl:323

Base's type printing code uses the REPL's currently active module to determine
how to print types. Unfortunately, this means it is illegal to use this in generated
functions. Switch to grabbing the symbol directly from the typename, since this now
errors on julia master:
```
  Got exception outside of a @test
  LoadError: MethodError: no method matching active_module()
  You may have intended to import Base.active_module
  The applicable method may be too new: running in world age 26446, while current world is 26576.

  Closest candidates are:
    active_module(::REPL.LineEditREPL) (method too new to be called from this world context.)
     @ REPL ~/julia/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:590
    active_module() (method too new to be called from this world context.)
     @ REPL ~/julia/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:586
    active_module(::REPL.REPLDisplay) (method too new to be called from this world context.)
     @ REPL ~/julia/usr/share/julia/stdlib/v1.11/REPL/src/REPL.jl:592
    ...

  Stacktrace:
    [1] #invokelatest#2
      @ ./essentials.jl:1025 [inlined]
    [2] invokelatest
      @ ./essentials.jl:1022 [inlined]
    [3] active_module
      @ ./show.jl:512 [inlined]
    [4] show_type_name(io::IOBuffer, tn::Core.TypeName)
      @ Base ./show.jl:1051
    [5] _show_type(io::IOBuffer, x::Type)
      @ Base ./show.jl:966
    [6] show(io::IOBuffer, x::Type)
      @ Base ./show.jl:963
    [7] print(io::IOBuffer, x::Type)
      @ Base ./strings/io.jl:35
    [8] print_to_string(xs::Type)
      @ Base ./strings/io.jl:148
    [9] string
      @ ./strings/io.jl:189 [inlined]
   [10] defaultalg_symbol(::Type{LinearSolve.LUFactorization{LinearAlgebra.RowMaximum}})
      @ LinearSolve ~/.julia/packages/LinearSolve/4aydZ/src/default.jl:323
```
Copy link

codecov bot commented Feb 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (49183f7) 66.06% compared to head (5525694) 65.99%.
Report is 15 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #466      +/-   ##
==========================================
- Coverage   66.06%   65.99%   -0.08%     
==========================================
  Files          27       27              
  Lines        2122     2120       -2     
==========================================
- Hits         1402     1399       -3     
- Misses        720      721       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ChrisRackauckas ChrisRackauckas merged commit 0598671 into SciML:main Feb 11, 2024
7 of 15 checks passed
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

Successfully merging this pull request may close these issues.

2 participants