Skip to content

Commit

Permalink
Fix #682.
Browse files Browse the repository at this point in the history
  • Loading branch information
paf31 committed Nov 6, 2014
1 parent ff6430a commit 89b0703
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
14 changes: 14 additions & 0 deletions examples/passing/ObjectUpdate2.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module Main where

type X r = { | r }

foreign import x "var x = {};" :: forall r. X r

blah :: forall r. X r -> X r
blah x = x

test = blah x
{ baz = "blah"
}

main = Debug.Trace.trace "Done"
7 changes: 4 additions & 3 deletions src/Language/PureScript/TypeChecker/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1018,10 +1018,11 @@ check' (TypeClassDictionaryConstructorApp name ps) t = do
return $ TypedValue True (TypeClassDictionaryConstructorApp name ps') t
check' (ObjectUpdate obj ps) t@(TypeApp o row) | o == tyObject = do
ensureNoDuplicateProperties ps
us <- zip (map fst ps) <$> replicateM (length ps) fresh
-- We need to be careful to avoid duplicate labels here.
-- We check _obj_ agaist the type _t_ with the types in _ps_ replaced with unknowns.
let (propsToCheck, rest) = rowToList row
propsToRemove = map fst ps
remainingProps = filter (\(p, _) -> p `notElem` propsToRemove) propsToCheck
(removedProps, remainingProps) = partition (\(p, _) -> p `elem` map fst ps) propsToCheck
us <- zip (map fst removedProps) <$> replicateM (length ps) fresh
obj' <- check obj (TypeApp tyObject (rowFromList (us ++ remainingProps, rest)))
ps' <- checkProperties ps row True
return $ TypedValue True (ObjectUpdate obj' ps') t
Expand Down

0 comments on commit 89b0703

Please sign in to comment.