unisonweb / unison

A friendly programming language from the future
https://unison-lang.org
Other
5.64k stars 267 forks source link

merge silently creates unnamed dependencies #5092

Closed ceedubs closed 1 week ago

ceedubs commented 2 weeks ago

Describe and demonstrate the bug

merge silently leads to unnamed dependencies when removing a constructor

Input:

```ucm
.> project.create-empty proj
proj/main> builtins.merge
type Foo = Bar | Baz

Foo.toText = cases
  Bar -> "Bar"
  Baz -> "Baz"
proj/main> add
proj/main> branch.create my-feature
boop = "boop"
proj/my-feature> add
type Foo = Bar

Foo.toText = cases
  Bar -> "Bar"
proj/main> update
proj/main> merge /my-feature
proj/main> namespace.dependencies

Output:
.> project.create-empty proj

  πŸŽ‰ I've created the project proj.

  🎨 Type `ui` to explore this project's code in your browser.
  πŸ”­ Discover libraries at https://share.unison-lang.org
  πŸ“– Use `help-topic projects` to learn more about projects.

  Write your first Unison code with UCM:

    1. Open scratch.u.
    2. Write some Unison code and save the file.
    3. In UCM, type `add` to save it to your new project.

  πŸŽ‰ πŸ₯³ Happy coding!

proj/main> builtins.merge

  Done.
type Foo = Bar | Baz

Foo.toText = cases
  Bar -> "Bar"
  Baz -> "Baz"

  Loading changes detected in scratch.u.

  I found and typechecked these definitions in scratch.u. If you
  do an `add` or `update`, here's how your codebase would
  change:

    ⍟ These new definitions are ok to `add`:

      type Foo
      Foo.toText : Foo -> Text
proj/main> add

  ⍟ I've added these definitions:

    type Foo
    Foo.toText : Foo -> Text

proj/main> branch.create my-feature

  Done. I've created the my-feature branch based off of main.

  Tip: To merge your work back into the main branch, first
       `switch /main` then `merge /my-feature`.
boop = "boop"

  Loading changes detected in scratch.u.

  I found and typechecked these definitions in scratch.u. If you
  do an `add` or `update`, here's how your codebase would
  change:

    ⍟ These new definitions are ok to `add`:

      boop : Text
proj/my-feature> add

  ⍟ I've added these definitions:

    boop : Text
type Foo = Bar

Foo.toText = cases
  Bar -> "Bar"

  Loading changes detected in scratch.u.

  I found and typechecked these definitions in scratch.u. If you
  do an `add` or `update`, here's how your codebase would
  change:

    ⍟ These names already exist. You can `update` them to your
      new definition:

      type Foo
      Foo.toText : Foo -> Text
proj/main> update

  Okay, I'm searching the branch for code that needs to be
  updated...

  Done.

proj/main> merge /my-feature

  I merged proj/my-feature into proj/main.

proj/main> namespace.dependencies

  External dependency   Dependents in .__projects._65f1b8da_a10c_4cf2_87c8_0c69bcedce2d.branches._35b964df_6577_4fd1_8d23_17c39d557347
  #j743idicb1#0         1. Foo.toText


**Environment (please complete the following information):**
 - `ucm --version` 0.5.21
 - OS/Architecture: x86 NixOS
mitchellwrosen commented 1 week ago

Fixed in #5110