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

"namespace" pragma problem re under-edit term names #5485

Open
kylegoetz opened this issue Dec 6, 2024 · 1 comment
Open

"namespace" pragma problem re under-edit term names #5485

kylegoetz opened this issue Dec 6, 2024 · 1 comment
Labels

Comments

@kylegoetz
Copy link
Contributor

Describe and demonstrate the bug

If "namespace" pragma exists in scratch file and then you edit something, terms will behave counterintuitively.

foo.bar = 5
fizz.bar = 6
scratch/main> add foo.bar fizz.bar
namespace foo
scratch/main> edit foo.bar fizz.bar

Now in the scratch file you'll essentially be creating foo.foo.bar and foo.fizz.bar instead of editing foo.bar and fizz.bar because the term names remain unaltered but the existence of namespace foo implicitly alters those term names.

Environment (please complete the following information):

  • ucm --version release/0.5.29
  • macOS 15

** What should happen**

I think what should happen is:

  1. for anything being edited that's part of the namespace, strip the namespace from the term when it's inserted into the scratch file
  2. for anything being edited that is not part of the namespace, append a "project root" prefix to the term name so it doesn't get added to the namespace when you add/update.
@kylegoetz kylegoetz added the bug label Dec 6, 2024
@mitchellwrosen
Copy link
Member

A namespace pragma unfortunately can't really be used safely in conjunction with edit. It's really only meant to speed up the authoring workflow for deeply-nested namespaces.

You might think we could render something like edit foo.bar.baz.qux as

namespace foo.bar.baz

qux = ...

but the problem is foo.bar.baz.qux could (for example) refer to itself and a term named qux:

foo.bar.baz.qux = ... foo.bar.baz.qux ... qux ...

That prevents us from putting a namespace foo.bar.baz directive, since it (by design) re-targets free variables (like qux) that refer to locally-bound top-level definitions.

So, in short, I wouldn't freely mix namespace directives with edit and expect things to work well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants