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

FR: Trigger on qualified macros as well #10

Closed
lgoettgens opened this issue Oct 22, 2024 · 2 comments · Fixed by #11
Closed

FR: Trigger on qualified macros as well #10

lgoettgens opened this issue Oct 22, 2024 · 2 comments · Fixed by #11
Labels
bug Something isn't working

Comments

@lgoettgens
Copy link

I often use Profile.Allocs.@profile without using Profile beforehand. I suppose this needs some small tweak in this package somewhere, to make the following part of my startup.jl work.

BasicAutoloads.register_autoloads([
        ["@profile", "Profile.Allocs.@profile"] => :(using Profile, PProf),
    ])
@LilithHafner
Copy link
Owner

Ah, this is actually a bug:

julia> BasicAutoloads.register_autoloads([
               ["foo"] => :(println("Foo!")),
               ["bar"] => :(println("Bar!")),
           ])

julia> foo
Foo!
ERROR: UndefVarError: `foo` not defined in `Main`
Suggestion: check for spelling errors or missing imports.

julia> x.bar
ERROR: UndefVarError: `x` not defined in `Main`
Suggestion: check for spelling errors or missing imports.
Stacktrace:
 [1] top-level scope
   @ REPL[7]:1

Entering Profile.Allocs.@profile in the REPL should but does not trigger autoloads for "@Profile".

@LilithHafner LilithHafner added the bug Something isn't working label Oct 22, 2024
@LilithHafner
Copy link
Owner

This is fixed in BasicAutoloads 1.0.2. Thanks for reporting!

You only need

BasicAutoloads.register_autoloads([
        ["@profile"] => :(using Profile, PProf),
    ])

the "Profile.Allocs.@profile" trigger will only match var"Profile.Allocs.@profile", not Profile.Allocs.@Profile. As per the docstring of BasicAutoloads.register_autoloads`

Each trigger must be a String. If the trigger is found as a symbol (e.g. variable, function, or macro name) in an input expression to the REPL...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants