on master help sign in
Instantiate the result type last
31396e5Evan Czaplicki
compiler/src/Type/Constrain/Expression.hs+8−8
@@ -726,22 +726,22 @@ data TypedArgs =
726
726
727constrainTypedArgs :: Map.Map N.Name Type -> N.Name -> [(Can.Pattern, Can.Type)] -> Can.Type -> IO TypedArgs
727constrainTypedArgs :: Map.Map N.Name Type -> N.Name -> [(Can.Pattern, Can.Type)] -> Can.Type -> IO TypedArgs
728constrainTypedArgs rtv name args srcResultType =
728constrainTypedArgs rtv name args srcResultType =
729− do resultType <- Instantiate.fromSrcType rtv srcResultType
730− typedArgsHelp rtv name Index.first args resultType Pattern.emptyState
729+ typedArgsHelp rtv name Index.first args srcResultType Pattern.emptyState
731
730
732
731
733−typedArgsHelp :: Map.Map N.Name Type -> N.Name -> Index.ZeroBased -> [(Can.Pattern, Can.Type)] -> Type -> Pattern.State -> IO TypedArgs
732+typedArgsHelp :: Map.Map N.Name Type -> N.Name -> Index.ZeroBased -> [(Can.Pattern, Can.Type)] -> Can.Type -> Pattern.State -> IO TypedArgs
734−typedArgsHelp rtv name index args resultType state =
733+typedArgsHelp rtv name index args srcResultType state =
735 case args of
734 case args of
736 [] ->
735 [] ->
736+ do resultType <- Instantiate.fromSrcType rtv srcResultType
737− return $ TypedArgs resultType resultType state
737+ return $ TypedArgs resultType resultType state
738
738
739 (pattern@(A.At region _), srcType) : otherArgs ->
739 (pattern@(A.At region _), srcType) : otherArgs ->
740 do argType <- Instantiate.fromSrcType rtv srcType
740 do argType <- Instantiate.fromSrcType rtv srcType
741 let expected = PFromContext region (PTypedArg name index) argType
741 let expected = PFromContext region (PTypedArg name index) argType
742
742
743− (TypedArgs tipe result newState) <-
743+ (TypedArgs tipe resultType newState) <-
744− typedArgsHelp rtv name (Index.next index) otherArgs resultType =<<
744+ typedArgsHelp rtv name (Index.next index) otherArgs srcResultType =<<
745 Pattern.add pattern expected state
745 Pattern.add pattern expected state
746
746
747− return (TypedArgs (FunN argType tipe) result newState)
747+ return (TypedArgs (FunN argType tipe) resultType newState)