mirror of
https://github.com/carp-lang/Carp.git
synced 2024-11-04 01:25:04 +03:00
fix: handle unhandled case in isCaptured (#1068)
Previously, this function missed a case, namely, one where the head of a type definition contains a concrete struct, like `Maybe` with a variable argument, `a`. That is, ``` (deftype (Foo (Maybe a)) [x (Maybe a)]) ``` Would throw a type error. This commit fixes that issue.
This commit is contained in:
parent
a0a3976441
commit
321671c74a
@ -138,7 +138,8 @@ canBeUsedAsMemberType typeEnv typeVariables ty xobj =
|
||||
-- `a` may be used as a member, sans `f`, but `f` may not appear
|
||||
-- without `a`.
|
||||
isCaptured :: Ty -> Ty -> Bool
|
||||
isCaptured t v@(VarTy _) = t == v
|
||||
isCaptured v@(VarTy _) t@(VarTy _) = t == v
|
||||
isCaptured sa@(StructTy (VarTy _) _) sb@(StructTy (VarTy _) _) = sa == sb
|
||||
isCaptured t (StructTy (VarTy _) vars) = t `elem` vars
|
||||
isCaptured _ _ = error "canbeusedasmembertype iscaptured"
|
||||
isCaptured v@(VarTy _) (StructTy _ vars) = v `elem` vars
|
||||
-- Not a variable.
|
||||
isCaptured _ _ = True
|
||||
|
Loading…
Reference in New Issue
Block a user