@@ -246,15 +246,10 @@ infer' (ObjectUpdate o ps) = do
246 o' <- TypedValue True <$> check o oldTy <*> pure oldTy
246 o' <- TypedValue True <$> check o oldTy <*> pure oldTy
247 return $ TypedValue True (ObjectUpdate o' newVals) $ TypeApp tyObject $ rowFromList (newTys, row)
247 return $ TypedValue True (ObjectUpdate o' newVals) $ TypeApp tyObject $ rowFromList (newTys, row)
248infer' (Accessor prop val) = do
248infer' (Accessor prop val) = do
249− typed@(TypedValue _ _ objTy) <- infer val
249+ field <- fresh
250− propTy <- inferProperty objTy prop
250+ rest <- fresh
255− _ <- subsumes Nothing objTy (TypeApp tyObject (RCons prop field rest))
251+ typed <- check val (TypeApp tyObject (RCons prop field rest))
256− return $ TypedValue True (Accessor prop typed) field
252+ return $ TypedValue True (Accessor prop typed) field
257− Just ty -> return $ TypedValue True (Accessor prop typed) ty
258infer' (Abs (Left arg) ret) = do
253infer' (Abs (Left arg) ret) = do
259 ty <- fresh
254 ty <- fresh
260 Just moduleName <- checkCurrentModule <$> get
255 Just moduleName <- checkCurrentModule <$> get
@@ -339,21 +334,6 @@ inferLetBinding seen (PositionedDeclaration pos com d : ds) ret j = warnAndRethr
339 return (PositionedDeclaration pos com d' : ds', val')
334 return (PositionedDeclaration pos com d' : ds', val')
340inferLetBinding _ _ _ _ = error "Invalid argument to inferLetBinding"
335inferLetBinding _ _ _ _ = error "Invalid argument to inferLetBinding"
343−-- Infer the type of a property inside a record with a given type
345−inferProperty :: Type -> String -> UnifyT Type Check (Maybe Type)
346−inferProperty (TypeApp obj row) prop | obj == tyObject = do
347− let (props, _) = rowToList row
348− return $ lookup prop props
349−inferProperty (SaturatedTypeSynonym name args) prop = do
350− replaced <- introduceSkolemScope <=< expandTypeSynonym name $ args
351− inferProperty replaced prop
352−inferProperty (ForAll ident ty _) prop = do
353− replaced <- replaceVarWithUnknown ident ty
354− inferProperty replaced prop
355−inferProperty _ _ = return Nothing
358-- Infer the types of variables brought into scope by a binder
338-- Infer the types of variables brought into scope by a binder