Skip to content

Commit

Permalink
feat(type-infer): Add a new error message in the case of multiple tya…
Browse files Browse the repository at this point in the history
…pps being detected (which shouldn't happen?)
  • Loading branch information
bristermitten committed Jun 1, 2024
1 parent 8503c23 commit 7486ea1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Elara/TypeInfer/Error.hs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ data TypeInferenceError where
KindInferError :: KindInferError -> TypeInferenceError
PartiallyAppliedConstructorPattern :: HasCallStack => TypeInferenceError
NotCustomType :: HasCallStack => SourceRegion -> Type SourceRegion -> TypeInferenceError
AmbiguousTypeApplication :: HasCallStack => SourceRegion -> [Type SourceRegion] -> TypeInferenceError

deriving instance Show TypeInferenceError

Expand Down
4 changes: 3 additions & 1 deletion src/Elara/TypeInfer/Infer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1372,11 +1372,13 @@ check expr@(Expr (Located exprLoc _, _)) t = debug ("check: " <> showPretty expr
-}
case _At of
Type.Forall{} -> do
debug' $ "applicableTyApp: " <> showPretty (_At, t) <> " => " <> showPretty (Type.applicableTyApp _At t)
case _At `Type.applicableTyApp` t of
[] -> pure _A
(tApp : _) ->
[tApp] ->
-- insert type application from instantiating the forall
pure $ Expr (Located exprLoc (TypeApplication _A tApp), _At `Type.instantiate` t)
more -> throw $ AmbiguousTypeApplication exprLoc more
_ -> pure _A

{- | This corresponds to the judgment:
Expand Down

0 comments on commit 7486ea1

Please sign in to comment.