ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
preprocessor.function_value_types Namespace Reference

Classes

class  _Scope
class  _Analysis

Functions

 _differ (a, b)
 _own_nodes (node)
 reject_mixed_function_values (module, path)

Variables

dict _NUMERIC = {"bool", "int", "float", "num"}
str _NONDET_PREFIX = "nondet_"
dict _SHOWN = {"num": "int or float", "function": "a function"}
tuple _NUMERIC_ONLY_OPS = (ast.FloorDiv, ast.Pow, ast.LShift, ast.RShift)
dict _BUILTIN_RESULTS

Detailed Description

Refuse a call through a function value that may return different types (#8404).

A call such as `g()`, where `g` may hold one of several functions, takes one
return type in the converter. When those functions return values of different
types, the result has the wrong type on every path but one, so `isinstance`
and comparisons give verdicts CPython disagrees with. Until the result can
carry its type per path, such a call is rejected.

The functions a value may hold are found by a flow-insensitive analysis over
one module: names, parameters, returns and container elements that a function
value flows through are merged into one group. A name is keyed by the scope
that binds it. A call through a value merges each function of its group's
arguments into that function's parameters and its returns into the call's
result, until nothing changes. A function whose return type cannot be told
from its source never causes a rejection.

Function Documentation

◆ _differ()

preprocessor.function_value_types._differ ( a,
b )
protected
Whether two known return kinds name different types.

◆ _own_nodes()

preprocessor.function_value_types._own_nodes ( node)
protected
The nodes of `node`'s own scope, with nested definitions but not their bodies.

◆ reject_mixed_function_values()

preprocessor.function_value_types.reject_mixed_function_values ( module,
path )
Raise NotImplementedError at a call through a value whose functions disagree.

Variable Documentation

◆ _BUILTIN_RESULTS

dict preprocessor.function_value_types._BUILTIN_RESULTS
protected
Initial value:
1= {
2 "str": "str",
3 "int": "int",
4 "float": "float",
5 "bool": "bool",
6 "len": "int",
7 "repr": "str",
8 "list": "list",
9 "dict": "dict",
10 "tuple": "tuple",
11 "set": "set"
12}

◆ _NONDET_PREFIX

str preprocessor.function_value_types._NONDET_PREFIX = "nondet_"
protected

◆ _NUMERIC

dict preprocessor.function_value_types._NUMERIC = {"bool", "int", "float", "num"}
protected

◆ _NUMERIC_ONLY_OPS

tuple preprocessor.function_value_types._NUMERIC_ONLY_OPS = (ast.FloorDiv, ast.Pow, ast.LShift, ast.RShift)
protected

◆ _SHOWN

dict preprocessor.function_value_types._SHOWN = {"num": "int or float", "function": "a function"}
protected