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

includet and include don't actually do the same thing, and they should. #682

Open
andyDoucette opened this issue May 16, 2022 · 8 comments

Comments

@andyDoucette
Copy link

andyDoucette commented May 16, 2022

Issue

include() evaluates the contents of the input source in the global scope of the module you're in.

includet() evaluates the contents of the input source in the Main module only.

This is a major source of issues, as users like me will expect includet() to be a "tracking" version of include, otherwise the same.

I just spent 3 hours debugging an issue where if I included code using Genie (which used a different Module than Main), the included methods were nowhere to be found, but if I included the code directly from the REPL it worked fine. It was challenging to figure out what's going on.

Request

Can we change the behavior of includet to use the module it's in instead of Main all the time? Should be as easy as using @MODULE() I hope?

@andyDoucette andyDoucette changed the title includet and include don't do the same thing includet and include don't actually do the same thing while importing, and they should. May 16, 2022
@andyDoucette andyDoucette changed the title includet and include don't actually do the same thing while importing, and they should. includet and include don't actually do the same thing, and they should. May 16, 2022
@pfitzseb
Copy link
Collaborator

I don't think there's a way for includet to stay a function and get its caller's scope. You can of course already use includet(@__MODULE__, "myfile.jl").

@andyDoucette
Copy link
Author

andyDoucette commented May 18, 2022 via email

@timholy
Copy link
Owner

timholy commented Jul 24, 2022

Impossible to say in the absence of the PR. But we merge PRs all the time here and in other packages.

Good PRs include a test and a clear motivation, and in this case the fact that you can use includet(@__MODULE__, "myfile.jl") seems like it undermines the need?

@Sixzero
Copy link

Sixzero commented Apr 22, 2023

Also LanguageServer doesn't track functions included in includet. Which I think affects every developer using includet but most of us just still keeps going even if such functionalities break and use find in the project!

As for the simplest MVP/fix is to change every includet to include and LanguageServer linkings will work, so LS navigations will work again.

This is a serious issue, I don't know if the two are connected, or I should just open a separate issue.

@timholy
Copy link
Owner

timholy commented Apr 22, 2023

That's funny because VSCode bundles Revise. So it knows about includet, and should be able to track things included that way.

@MasonProtter
Copy link

We could just make an @includet macro?

@pfitzseb
Copy link
Collaborator

Sure, but I still don't quite see the motivation for this.

@timholy timholy closed this as completed Sep 26, 2024
@MasonProtter
Copy link

I don't think this should be closed. includet not evaluating into the module its located in is still quite the footgun.

@timholy timholy reopened this Sep 28, 2024
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

5 participants