Changed the abbreviation checking so that it doesn't check nonce names
When we pull up names (which happens before abbreviation checking), we create a lot of nonces with greater scope than the original variables. When we go to abbreviation check this, we therefore set off lots of false alarms about originally safe code. So to fix this, the easiest method seems to be turning off checking on all the names introduced by the compiler.
This commit is contained in:
parent
18f23bf767
commit
152f5fc252
|
@ -210,21 +210,37 @@ abbrevCheckPass
|
|||
|
||||
record b v = modify (\(m:ms) -> (Map.insertWith (||) (Var v) b m : ms))
|
||||
|
||||
nameIsNonce :: A.Name -> StateT [Map.Map Var Bool] PassM Bool
|
||||
nameIsNonce n
|
||||
= do names <- lift getCompState >>* csNames
|
||||
case fmap A.ndNameSource $ Map.lookup (A.nameName n) names of
|
||||
Just A.NameNonce -> return True
|
||||
_ -> return False
|
||||
|
||||
doStructured :: Data a => A.Structured a -> StateT [Map.Map Var Bool] PassM
|
||||
(A.Structured a)
|
||||
doStructured s@(A.Spec _ (A.Specification _ n (A.Is _ A.Abbrev _ v)) scope)
|
||||
= do pushRecurse scope
|
||||
= do nonce <- nameIsNonce n
|
||||
if nonce
|
||||
then descend s >> return ()
|
||||
else do pushRecurse scope
|
||||
checkAbbreved v "Abbreviated variable % used inside the scope of the abbreviation"
|
||||
pop
|
||||
return s
|
||||
doStructured s@(A.Spec _ (A.Specification m n (A.Is _ A.ValAbbrev _ v)) scope)
|
||||
= do pushRecurse scope
|
||||
= do nonce <- nameIsNonce n
|
||||
if nonce
|
||||
then descend s >> return ()
|
||||
else do pushRecurse scope
|
||||
checkAbbreved v "Abbreviated variable % used inside the scope of the abbreviation"
|
||||
checkNotWritten (A.Variable m n) "VAL-abbreviated variable % written-to inside the scope of the abbreviation"
|
||||
pop
|
||||
return s
|
||||
doStructured s@(A.Spec _ (A.Specification m n (A.IsExpr _ A.ValAbbrev _ e)) scope)
|
||||
= do pushRecurse scope
|
||||
= do nonce <- nameIsNonce n
|
||||
if nonce
|
||||
then descend s >> return ()
|
||||
else do pushRecurse scope
|
||||
checkNotWritten (A.Variable m n) "VAL-abbreviated variable % written-to inside the scope of the abbreviation"
|
||||
sequence_ [checkNotWritten v
|
||||
"Abbreviated variable % used inside the scope of the abbreviation"
|
||||
|
|
Loading…
Reference in New Issue
Block a user