Don't allow uppercase pattern variables
This commit is contained in:
@@ -212,3 +212,6 @@ record OpDef where
|
||||
|
||||
Operators : U
|
||||
Operators = SortedMap String OpDef
|
||||
|
||||
isUpperName : String → Bool
|
||||
isUpperName nm = isUpper $ strIndex nm 0
|
||||
|
||||
@@ -1001,7 +1001,10 @@ mkPat (tm, icit) = do
|
||||
-- Just _ => error (getFC tm) "\{show nm} is not a data constructor"
|
||||
_ => case b of
|
||||
-- TODO maybe check case?
|
||||
Nil => pure $ PatVar fc icit nm
|
||||
Nil =>
|
||||
if isUpperName nm
|
||||
then error (getFC tm) "\{nm} not in scope"
|
||||
else pure $ PatVar fc icit nm
|
||||
_ => error (getFC tm) "patvar applied to args"
|
||||
((RImplicit fc), Nil) => pure $ PatWild fc icit
|
||||
((RImplicit fc), _) => error fc "implicit pat can't be applied to arguments"
|
||||
|
||||
Reference in New Issue
Block a user