@@ -333,7 +333,8 @@ vrdHelp commentedDecls ports structure =
333333 vrdDefHelp rest (A.A (region, snd ann) def) ports structure
334334
335335 D.Port name tipe ->
336− vrdHelp rest (A.A ann (Effects.PortRaw name tipe) : ports) structure
336+ do checkDuplicateFieldsInType tipe
337+ vrdHelp rest (A.A ann (Effects.PortRaw name tipe) : ports) structure
337338
338339
339340vrdDefHelp
@@ -414,6 +415,7 @@ validateDef
414415validateDef region pat expr maybeType =
415416 do validExpr <- expression expr
416417 validateDefPattern pat validExpr
418+ F.traverse_ checkDuplicateFieldsInType maybeType
417419 return $ Src.Def region pat validExpr maybeType
418420
419421
@@ -685,3 +687,25 @@ freeVars (A.A region tipe) =
685687 do checkDuplicateFields region fields
686688 let types = Maybe.maybeToList ext ++ map snd fields
687689 concat <$> traverse freeVars types
690+
691+
692+checkDuplicateFieldsInType :: Type.Raw -> Result wrn ()
693+checkDuplicateFieldsInType (A.A region tipe) =
694+ case tipe of
695+ Type.RLambda t1 t2 ->
696+ checkDuplicateFieldsInType t1
697+ <* checkDuplicateFieldsInType t2
698+
699+ Type.RVar _ ->
700+ Result.ok ()
701+
702+ Type.RType _ ->
703+ Result.ok ()
704+
705+ Type.RApp t ts ->
706+ F.traverse_ checkDuplicateFieldsInType (t:ts)
707+
708+ Type.RRecord fields ext ->
709+ do checkDuplicateFields region fields
710+ let types = Maybe.maybeToList ext ++ map snd fields
711+ F.traverse_ checkDuplicateFieldsInType types