hpython-0.3: Python language tools

Copyright(C) CSIRO 2017-2019
LicenseBSD3
MaintainerIsaac Elliott <isaace71295@gmail.com>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Language.Python.Validate.Scope.Error

Description

 

Documentation

data ScopeError a Source #

Constructors

FoundNonlocal a

Using nonlocal to modify function scopes makes scope checking intractible

FoundGlobal a

Using global to add identifiers to the global scope makes scope checking intractible

DeletedIdent a

Using del to remove identifiers from scope makes scope checking intractible

FoundDynamic a (Ident '[] a)

Variable assignments deep in control flow can modify the scope outside the control flow. For example:

if a:
    x = 0
else:
    pass

print(x)

x will be in scope if the True branch was entered, but not if the False branch was entered. This kind of behaviour makes scope checking intractible, so programs like this are considered scope errors.

NotInScope (Ident '[] a)

An identifier is not in scope

BadShadowing (Ident '[] a)

For loops don't execute in a fresh scope, so if the counter of the loop shadows a variable, then that variable will be mutated.

e.g.

x = 0
for x in 1, 2, 3:
   pass
print(x)

outputs 3

This error occurs when we spot this pattern.