1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2024-06-01 12:41:30 +00:00

Introduce yet another new error.

This commit is contained in:
Chris Pressey 2018-11-27 17:09:38 +00:00
parent a53a3529ea
commit 07ec6752ee

View File

@ -34,6 +34,11 @@ class InconsistentInitializationError(StaticAnalysisError):
pass
class InconsistentExitError(StaticAnalysisError):
"""The type context differs at two different exit points of the routine."""
pass
class ForbiddenWriteError(StaticAnalysisError):
pass
@ -156,6 +161,10 @@ class Context(object):
for ref in self._touched:
yield ref
def each_writeable(self):
for ref in self._writeable:
yield ref
def assert_meaningful(self, *refs, **kwargs):
exception_class = kwargs.get('exception_class', UnmeaningfulReadError)
for ref in refs:
@ -419,12 +428,14 @@ class Analyzer(object):
exit_context = self.exit_contexts[0]
exit_meaningful = set(exit_context.each_meaningful())
exit_touched = set(exit_context.each_touched())
exit_writeable = set(exit_context.each_writeable())
for ex in self.exit_contexts[1:]:
if set(ex.each_meaningful()) != exit_meaningful:
raise InconsistentInitializationError('?')
raise InconsistentExitError("Exit contexts are not consistent")
if set(ex.each_touched()) != exit_touched:
raise InconsistentInitializationError('?')
# FIXME: confirm writeable sets are the same too?
raise InconsistentExitError("Exit contexts are not consistent")
if set(ex.each_writeable()) != exit_writeable:
raise InconsistentExitError("Exit contexts are not consistent")
context.update_from(exit_context)
trashed = set(context.each_touched()) - set(context.each_meaningful())