Introduce yet another new error.
Chris Pressey
6 years ago
30 | 30 | |
31 | 31 | |
32 | 32 | class InconsistentInitializationError(StaticAnalysisError): |
33 | pass | |
34 | ||
35 | ||
36 | class InconsistentExitError(StaticAnalysisError): | |
37 | """The type context differs at two different exit points of the routine.""" | |
33 | 38 | pass |
34 | 39 | |
35 | 40 | |
153 | 158 | |
154 | 159 | def each_touched(self): |
155 | 160 | for ref in self._touched: |
161 | yield ref | |
162 | ||
163 | def each_writeable(self): | |
164 | for ref in self._writeable: | |
156 | 165 | yield ref |
157 | 166 | |
158 | 167 | def assert_meaningful(self, *refs, **kwargs): |
418 | 427 | exit_context = self.exit_contexts[0] |
419 | 428 | exit_meaningful = set(exit_context.each_meaningful()) |
420 | 429 | exit_touched = set(exit_context.each_touched()) |
430 | exit_writeable = set(exit_context.each_writeable()) | |
421 | 431 | for ex in self.exit_contexts[1:]: |
422 | 432 | if set(ex.each_meaningful()) != exit_meaningful: |
423 | raise InconsistentInitializationError('?') | |
433 | raise InconsistentExitError("Exit contexts are not consistent") | |
424 | 434 | if set(ex.each_touched()) != exit_touched: |
425 | raise InconsistentInitializationError('?') | |
426 | # FIXME: confirm writeable sets are the same too? | |
435 | raise InconsistentExitError("Exit contexts are not consistent") | |
436 | if set(ex.each_writeable()) != exit_writeable: | |
437 | raise InconsistentExitError("Exit contexts are not consistent") | |
427 | 438 | context.update_from(exit_context) |
428 | 439 | |
429 | 440 | trashed = set(context.each_touched()) - set(context.each_meaningful()) |