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

simplify and improve printing of qualified names #39841

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

JeffBezanson
Copy link
Member

This removes repeated code, fixes some cases where quoting was not done
correcly (e.g. Mod.:+), and checks identifier visibility recursively
so only a minimal module path is printed.

fixes #39834

@JeffBezanson JeffBezanson added the display and printing Aesthetics and correctness of printed representations of objects. label Feb 26, 2021
@JeffBezanson
Copy link
Member Author

Ah, so Documenter uses a temporary module with an invalid identifier name plus some regex magic, which is causing the weird Main.var"Main" printing. Our options:

  • Don't use var"" here, rolling back part of the fix. That would be bad because we were printing these incorrectly before.
  • Add var"..." to the doctest heuristics.
  • Use a valid identifier for the doctest sandbox name

This removes repeated code, fixes some cases where quoting was not done
correcly (e.g. `Mod.:+`), and checks identifier visibility recursively
so only a minimal module path is printed.

fixes #39834
@JeffBezanson
Copy link
Member Author

JeffBezanson commented Mar 4, 2021

Of course this ended up being much more involved than you'd think. The main issue seems to be whether to do this for print/string as well as show/repr. So far I kept the output of print(::Module) the same (always fully qualified) to try to be less breaking. However, that still breaks some tests similar to

@test sprint(show, x) == "$(@__MODULE__).A.B.x"

since interpolation uses print. So the questions are

  1. Should we do the new auto-qualification for both print and show?
  2. Should we address RFC: make default module-prefix showing independent of the state of Main(e) #29466 at the same time?

If print and show are different, that can be confusing of course. But if they're the same, we hit #29466 in that the result of string(x) or interpolation can change based on using things at the prompt. But that trades off against lots of package tests relying on the Main behavior --- the test file does using MyPackage, so it's visible in Main, so things will print un-qualified. Maybe we could add some feature to temporarily change the global default module setting for printing?

@JeffBezanson
Copy link
Member Author

Triage says: this is maybe justifiable if we combine it with something else that makes it easier to write these kinds of tests. Maybe combining it with #29466 would do that, by making repr(x) by itself more predictable.

@vtjnash vtjnash added this to the 1.8 milestone May 27, 2021
@vtjnash vtjnash removed the triage This should be discussed on a triage call label May 27, 2021
@JeffBezanson JeffBezanson removed this from the 1.8 milestone Feb 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
display and printing Aesthetics and correctness of printed representations of objects.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Do not show full name of modules if they are available from Main
2 participants