Skip to content

@u_str macro hygiene? #272

@goretkin

Description

@goretkin

I'm not sure if this is intentional or not, but I expected it to be sufficient to just import Unitful: @u_str in order to use e.g. u"m".

julia> import Unitful: @u_str

julia> u"m"
ERROR: LoadError: Symbol `m` was found in unit module Unitful, but was not loaded into Main. Consider `using Unitful` within `Main`?
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] replace_value(::Module, ::Symbol) at /Users/goretkin/.julia/packages/Unitful/ytsW0/src/user.jl:550
 [3] @u_str(::LineNumberNode, ::Module, ::Any) at /Users/goretkin/.julia/packages/Unitful/ytsW0/src/user.jl:505
in expression starting at REPL[4]:1

julia> import Unitful: m

julia> u"m"
ERROR: LoadError: Symbol `m` was found in unit module Unitful, but was not loaded into Main. Consider `using Unitful` within `Main`?
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] replace_value(::Module, ::Symbol) at /Users/goretkin/.julia/packages/Unitful/ytsW0/src/user.jl:550
 [3] @u_str(::LineNumberNode, ::Module, ::Any) at /Users/goretkin/.julia/packages/Unitful/ytsW0/src/user.jl:505
in expression starting at REPL[6]:1

julia> using Unitful

julia> u"m"
m

julia> m = "garbage"
ERROR: cannot assign a value to variable Unitful.m from module Main
Stacktrace:
 [1] top-level scope at REPL[9]:1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions