Skip to content

Commit

Permalink
Merge pull request #4404 from unisonweb/4399-tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
aryairani authored Nov 20, 2023
2 parents 160c252 + c33bf9c commit ba27a94
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion unison-cli/src/Unison/Codebase/Editor/HandleInput/Update2.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import Data.Map qualified as Map
import Data.Maybe (fromJust)
import Data.Set qualified as Set
import Data.Text qualified as Text
import Data.Text.Lazy qualified as Lazy.Text
import Text.Pretty.Simple (pShow)
import U.Codebase.Reference (Reference, ReferenceType)
import U.Codebase.Reference qualified as Reference
import U.Codebase.Sqlite.Operations qualified as Ops
Expand Down Expand Up @@ -324,7 +326,18 @@ addDefinitionsToUnisonFile abort c names ctorNames dependents initialUnisonFile
let constructorNames :: Transaction [Symbol]
constructorNames = case findCtorNames names ctorNames (Just $ Decl.constructorCount dd) name of
Left err -> abort err
Right array -> pure $ Name.toVar . fromJust . Name.stripNamePrefix name <$> array
Right array ->
case traverse (fmap Name.toVar . Name.stripNamePrefix name) array of
Just varArray -> pure varArray
Nothing -> do
traceM "I ran into a situation where a type's constructors didn't match its name,"
traceM "in a spot where I didn't expect to be discovering that.\n\n"
traceM "Type Name:"
traceM . Lazy.Text.unpack $ pShow name
traceM "Constructor Names:"
traceM . Lazy.Text.unpack $ pShow array
error "Sorry for crashing."

swapConstructorNames oldCtors =
let (annotations, _vars, types) = unzip3 oldCtors
in zip3 annotations <$> constructorNames <*> pure types
Expand Down

0 comments on commit ba27a94

Please sign in to comment.