unisonweb / unison

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

Crash when doing an update that adds a constructor #4399

Open pchiusano opened 11 months ago

pchiusano commented 11 months ago

Reported by Kyle Goetz

unique type model.ResourceType
  = Device
  | BridgeHome
  -- [snip]
  | SmartScene
  | Taurus
The only thing I’ve done is add | Taurus to the end.
When I run update:
huenison/backup> update

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

  That's done. Now I'm making sure everything typechecks...

Encountered exception:
Maybe.fromJust: Nothing
CallStack (from HasCallStack):
  error, called at libraries/base/Data/Maybe.hs:149:21 in base:Data.Maybe
  fromJust, called at src/Unison/Codebase/Editor/HandleInput/Update2.hs:327:52 in unison-cli-0.0.0-IVNBXmTzObr3Tub8V1XXEr:Unison.Codebase.Editor.HandleInput.Update2
aryairani commented 11 months ago

Yikes, unexpected. Thanks for the report.

aryairani commented 11 months ago

A simple case doesn't crash:

```ucm:hide
.> project.create test
unique type Foo = A | B
test/main> add
unique type Foo = A | B | C
test/main> update
aryairani commented 11 months ago

This case also doesn't crash, but does print an error asking you to add constructors for Bar

```ucm:hide
.> project.create test
unique type Foo = A | B
test/main> add
test/main> alias.type Foo Bar
unique type Bar = A | B | C
test/main> update
aryairani commented 11 months ago

This does reproduce it, though it's a long-ish download:

```ucm:hide
.> clone @kylegoetz/huenison/fromjust-bug
unique type model.ResourceId
    = ResourceId.internal (Text, Text, Text, Text, Text)
@kylegoetz/huenison/fromjust-bug> update


Note that this repro does not add a constructor, it just renames one.