Skip to content

u"Ω" errors in precompilation #105

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

Closed
YingboMa opened this issue Jan 4, 2024 · 6 comments · Fixed by #106
Closed

u"Ω" errors in precompilation #105

YingboMa opened this issue Jan 4, 2024 · 6 comments · Fixed by #106

Comments

@YingboMa
Copy link

YingboMa commented Jan 4, 2024

MWE: write the literalu"Ω" in a package that precompiles.

caused by: LoadError: Evaluation into the closed module `UnitsParse` breaks incremental compilation because the side effects will not be permanent. This is likely due to some other module mutating `UnitsParse` with `eval` during precompilation - don't do this.
Stacktrace:
  [1] eval
    @ Core ./boot.jl:385 [inlined]
  [2] eval
    @ DynamicQuantities.UnitsParse ~/.julia/packages/DynamicQuantities/5QflN/src/uparse.jl:1 [inlined]
  [3] uparse(s::String)
    @ DynamicQuantities.UnitsParse ~/.julia/packages/DynamicQuantities/5QflN/src/uparse.jl:37
  [4] var"@u_str"(__source__::LineNumberNode, __module__::Module, s::Any)
    @ DynamicQuantities.UnitsParse ~/.julia/packages/DynamicQuantities/5QflN/src/uparse.jl:57
...
@MilesCranmer
Copy link
Member

MilesCranmer commented Jan 4, 2024

As a quick fix you could do import DynamicQuantities.Units: Ω (or .SymbolicUnits: Ω) and work with the symbols directly.

It's weird that precompilation doesn't like the string version. Does anything in that module jump out to you? This is the file:

module UnitsParse

@YingboMa
Copy link
Author

YingboMa commented Jan 4, 2024

It's probably due to the eval in

return as_quantity(eval(Meta.parse(s)))::DEFAULT_QUANTITY_TYPE

@MilesCranmer
Copy link
Member

Oh I see. What other options are there for implementing this?

@YingboMa
Copy link
Author

YingboMa commented Jan 4, 2024

You can evaluate the expression yourself instead of eval.

@MilesCranmer
Copy link
Member

Ah. Of course 🤦‍♂️

Thanks, will fix.

@MilesCranmer
Copy link
Member

MilesCranmer commented Jan 4, 2024

I guess we’ll need to do something a bit more complex like https://github.com/PainterQubits/Unitful.jl/blob/a09bdaac255d456e6315b77979a48956aca1d3a3/src/user.jl#L692 to get this working without eval.

Working on this in #106.

Edit: fixed!

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 a pull request may close this issue.

2 participants