Skip to content

Commit

Permalink
Minimal fix for issue #2241
Browse files Browse the repository at this point in the history
This fixes #2241

Preliminary testing seems to indicate this isn't as bad of a slowdown as
it may seem. For more details see Zokka-Dev/zokka-compiler#20

This is meant as a reference PR for other people working on the Elm
compiler.
  • Loading branch information
changlinli committed Jul 17, 2024
1 parent 2f6dd29 commit 248696f
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions compiler/src/Type/Unify.hs
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,20 @@ fresh (Context _ (Descriptor _ rank1 _ _) _ (Descriptor _ rank2 _ _)) content =
guardedUnify :: Variable -> Variable -> Unify ()
guardedUnify left right =
Unify $ \vars ok err ->
do equivalent <- UF.equivalent left right
if equivalent
then ok vars ()
do occursLeft <- Occurs.occurs left
occursRight <- Occurs.occurs right
if occursLeft || occursRight
then err vars ()
else
do leftDesc <- UF.get left
rightDesc <- UF.get right
case actuallyUnify (Context left leftDesc right rightDesc) of
Unify k ->
k vars ok err
equivalent <- UF.equivalent left right
if equivalent
then ok vars ()
else
do leftDesc <- UF.get left
rightDesc <- UF.get right
case actuallyUnify (Context left leftDesc right rightDesc) of
Unify k ->
k vars ok err


subUnify :: Variable -> Variable -> Unify ()
Expand Down

0 comments on commit 248696f

Please sign in to comment.