Don't allow uppercase pattern variables
This commit is contained in:
@@ -212,3 +212,6 @@ record OpDef where
|
|||||||
|
|
||||||
Operators : U
|
Operators : U
|
||||||
Operators = SortedMap String OpDef
|
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"
|
-- Just _ => error (getFC tm) "\{show nm} is not a data constructor"
|
||||||
_ => case b of
|
_ => case b of
|
||||||
-- TODO maybe check case?
|
-- 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"
|
_ => error (getFC tm) "patvar applied to args"
|
||||||
((RImplicit fc), Nil) => pure $ PatWild fc icit
|
((RImplicit fc), Nil) => pure $ PatWild fc icit
|
||||||
((RImplicit fc), _) => error fc "implicit pat can't be applied to arguments"
|
((RImplicit fc), _) => error fc "implicit pat can't be applied to arguments"
|
||||||
|
|||||||
6
tests/LowerPatVar.newt
Normal file
6
tests/LowerPatVar.newt
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
module LowerPatVar
|
||||||
|
|
||||||
|
import Prelude
|
||||||
|
|
||||||
|
foo : Nat × Nat → Nat
|
||||||
|
foo (ZZ , y) = Z
|
||||||
10
tests/LowerPatVar.newt.fail
Normal file
10
tests/LowerPatVar.newt.fail
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
*** Process tests/LowerPatVar.newt
|
||||||
|
module Prelude
|
||||||
|
module LowerPatVar
|
||||||
|
ERROR at tests/LowerPatVar.newt:6:6--6:8: ZZ not in scope
|
||||||
|
|
||||||
|
foo : Nat × Nat → Nat
|
||||||
|
foo (ZZ , y) = Z
|
||||||
|
^^
|
||||||
|
|
||||||
|
ERROR at tests/LowerPatVar.newt:1:1--1:1: Compile failed
|
||||||
@@ -66,7 +66,7 @@ data Sg : (A : U) -> (A -> U) -> U where
|
|||||||
_,_ : {A : U} {B : A -> U} -> (a : A) -> B a -> Sg A B
|
_,_ : {A : U} {B : A -> U} -> (a : A) -> B a -> Sg A B
|
||||||
|
|
||||||
_*_ : U -> U -> U
|
_*_ : U -> U -> U
|
||||||
A * B = Sg A (\ _ => B)
|
a * b = Sg a (\ _ => b)
|
||||||
|
|
||||||
TooBig : Bnd -> Bnd -> Nat -> U
|
TooBig : Bnd -> Bnd -> Nat -> U
|
||||||
TooBig l u h = Sg Nat (\ x => T23 l (N x) h * T23 (N x) u h)
|
TooBig l u h = Sg Nat (\ x => T23 l (N x) h * T23 (N x) u h)
|
||||||
|
|||||||
Reference in New Issue
Block a user