add support for enum max/min members, fix min member on elementary (#1276)

pull/1300/head
alpharush 2 years ago committed by GitHub
parent 63a154fbb0
commit 98e6d8c13e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      slither/core/declarations/enum.py
  2. 3
      slither/core/solidity_types/type_information.py
  3. 18
      slither/visitors/slithir/expression_to_slithir.py
  4. BIN
      tests/ast-parsing/compile/minmax-0.6.8.sol-0.6.8-compact.zip
  5. BIN
      tests/ast-parsing/compile/minmax-0.6.8.sol-0.6.8-legacy.zip
  6. BIN
      tests/ast-parsing/compile/minmax-0.6.8.sol-0.6.9-compact.zip
  7. BIN
      tests/ast-parsing/compile/minmax-0.6.8.sol-0.6.9-legacy.zip
  8. BIN
      tests/ast-parsing/compile/minmax-0.6.8.sol-0.7.0-compact.zip
  9. BIN
      tests/ast-parsing/compile/minmax-0.6.8.sol-0.7.0-legacy.zip
  10. BIN
      tests/ast-parsing/compile/minmax-0.6.8.sol-0.7.1-compact.zip
  11. BIN
      tests/ast-parsing/compile/minmax-0.6.8.sol-0.7.1-legacy.zip
  12. BIN
      tests/ast-parsing/compile/minmax-0.6.8.sol-0.7.2-compact.zip
  13. BIN
      tests/ast-parsing/compile/minmax-0.6.8.sol-0.7.2-legacy.zip
  14. BIN
      tests/ast-parsing/compile/minmax-0.6.8.sol-0.7.3-compact.zip
  15. BIN
      tests/ast-parsing/compile/minmax-0.6.8.sol-0.7.3-legacy.zip
  16. BIN
      tests/ast-parsing/compile/minmax-0.6.8.sol-0.7.4-compact.zip
  17. BIN
      tests/ast-parsing/compile/minmax-0.6.8.sol-0.7.4-legacy.zip
  18. BIN
      tests/ast-parsing/compile/minmax-0.6.8.sol-0.7.5-compact.zip
  19. BIN
      tests/ast-parsing/compile/minmax-0.6.8.sol-0.7.5-legacy.zip
  20. BIN
      tests/ast-parsing/compile/minmax-0.6.8.sol-0.7.6-compact.zip
  21. BIN
      tests/ast-parsing/compile/minmax-0.6.8.sol-0.7.6-legacy.zip
  22. BIN
      tests/ast-parsing/compile/minmax-0.6.8.sol-0.8.0-compact.zip
  23. BIN
      tests/ast-parsing/compile/minmax-0.6.8.sol-0.8.1-compact.zip
  24. BIN
      tests/ast-parsing/compile/minmax-0.6.8.sol-0.8.10-compact.zip
  25. BIN
      tests/ast-parsing/compile/minmax-0.6.8.sol-0.8.11-compact.zip
  26. BIN
      tests/ast-parsing/compile/minmax-0.6.8.sol-0.8.12-compact.zip
  27. BIN
      tests/ast-parsing/compile/minmax-0.6.8.sol-0.8.2-compact.zip
  28. BIN
      tests/ast-parsing/compile/minmax-0.6.8.sol-0.8.3-compact.zip
  29. BIN
      tests/ast-parsing/compile/minmax-0.6.8.sol-0.8.4-compact.zip
  30. BIN
      tests/ast-parsing/compile/minmax-0.6.8.sol-0.8.5-compact.zip
  31. BIN
      tests/ast-parsing/compile/minmax-0.6.8.sol-0.8.6-compact.zip
  32. BIN
      tests/ast-parsing/compile/minmax-0.6.8.sol-0.8.7-compact.zip
  33. BIN
      tests/ast-parsing/compile/minmax-0.6.8.sol-0.8.8-compact.zip
  34. BIN
      tests/ast-parsing/compile/minmax-0.6.8.sol-0.8.9-compact.zip
  35. BIN
      tests/ast-parsing/compile/minmax-0.8.8.sol-0.8.10-compact.zip
  36. BIN
      tests/ast-parsing/compile/minmax-0.8.8.sol-0.8.11-compact.zip
  37. BIN
      tests/ast-parsing/compile/minmax-0.8.8.sol-0.8.12-compact.zip
  38. BIN
      tests/ast-parsing/compile/minmax-0.8.8.sol-0.8.13-compact.zip
  39. BIN
      tests/ast-parsing/compile/minmax-0.8.8.sol-0.8.14-compact.zip
  40. BIN
      tests/ast-parsing/compile/minmax-0.8.8.sol-0.8.15-compact.zip
  41. BIN
      tests/ast-parsing/compile/minmax-0.8.8.sol-0.8.8-compact.zip
  42. BIN
      tests/ast-parsing/compile/minmax-0.8.8.sol-0.8.9-compact.zip
  43. 4
      tests/ast-parsing/expected/minmax-0.6.8.sol-0.6.8-compact.json
  44. 4
      tests/ast-parsing/expected/minmax-0.6.8.sol-0.6.8-legacy.json
  45. 4
      tests/ast-parsing/expected/minmax-0.6.8.sol-0.6.9-compact.json
  46. 4
      tests/ast-parsing/expected/minmax-0.6.8.sol-0.6.9-legacy.json
  47. 4
      tests/ast-parsing/expected/minmax-0.6.8.sol-0.7.0-compact.json
  48. 4
      tests/ast-parsing/expected/minmax-0.6.8.sol-0.7.0-legacy.json
  49. 4
      tests/ast-parsing/expected/minmax-0.6.8.sol-0.7.1-compact.json
  50. 4
      tests/ast-parsing/expected/minmax-0.6.8.sol-0.7.1-legacy.json
  51. 4
      tests/ast-parsing/expected/minmax-0.6.8.sol-0.7.2-compact.json
  52. 4
      tests/ast-parsing/expected/minmax-0.6.8.sol-0.7.2-legacy.json
  53. 4
      tests/ast-parsing/expected/minmax-0.6.8.sol-0.7.3-compact.json
  54. 4
      tests/ast-parsing/expected/minmax-0.6.8.sol-0.7.3-legacy.json
  55. 4
      tests/ast-parsing/expected/minmax-0.6.8.sol-0.7.4-compact.json
  56. 4
      tests/ast-parsing/expected/minmax-0.6.8.sol-0.7.4-legacy.json
  57. 4
      tests/ast-parsing/expected/minmax-0.6.8.sol-0.7.5-compact.json
  58. 4
      tests/ast-parsing/expected/minmax-0.6.8.sol-0.7.5-legacy.json
  59. 4
      tests/ast-parsing/expected/minmax-0.6.8.sol-0.7.6-compact.json
  60. 4
      tests/ast-parsing/expected/minmax-0.6.8.sol-0.7.6-legacy.json
  61. 4
      tests/ast-parsing/expected/minmax-0.6.8.sol-0.8.0-compact.json
  62. 4
      tests/ast-parsing/expected/minmax-0.6.8.sol-0.8.1-compact.json
  63. 4
      tests/ast-parsing/expected/minmax-0.6.8.sol-0.8.10-compact.json
  64. 4
      tests/ast-parsing/expected/minmax-0.6.8.sol-0.8.11-compact.json
  65. 4
      tests/ast-parsing/expected/minmax-0.6.8.sol-0.8.12-compact.json
  66. 4
      tests/ast-parsing/expected/minmax-0.6.8.sol-0.8.2-compact.json
  67. 4
      tests/ast-parsing/expected/minmax-0.6.8.sol-0.8.3-compact.json
  68. 4
      tests/ast-parsing/expected/minmax-0.6.8.sol-0.8.4-compact.json
  69. 4
      tests/ast-parsing/expected/minmax-0.6.8.sol-0.8.5-compact.json
  70. 4
      tests/ast-parsing/expected/minmax-0.6.8.sol-0.8.6-compact.json
  71. 4
      tests/ast-parsing/expected/minmax-0.6.8.sol-0.8.7-compact.json
  72. 4
      tests/ast-parsing/expected/minmax-0.6.8.sol-0.8.8-compact.json
  73. 4
      tests/ast-parsing/expected/minmax-0.6.8.sol-0.8.9-compact.json
  74. 7
      tests/ast-parsing/expected/minmax-0.8.8.sol-0.8.10-compact.json
  75. 7
      tests/ast-parsing/expected/minmax-0.8.8.sol-0.8.11-compact.json
  76. 7
      tests/ast-parsing/expected/minmax-0.8.8.sol-0.8.12-compact.json
  77. 7
      tests/ast-parsing/expected/minmax-0.8.8.sol-0.8.13-compact.json
  78. 7
      tests/ast-parsing/expected/minmax-0.8.8.sol-0.8.14-compact.json
  79. 7
      tests/ast-parsing/expected/minmax-0.8.8.sol-0.8.15-compact.json
  80. 7
      tests/ast-parsing/expected/minmax-0.8.8.sol-0.8.8-compact.json
  81. 7
      tests/ast-parsing/expected/minmax-0.8.8.sol-0.8.9-compact.json
  82. 12
      tests/ast-parsing/minmax-0.6.8.sol
  83. 29
      tests/ast-parsing/minmax-0.8.8.sol
  84. 4
      tests/test_ast_parsing.py

@ -9,6 +9,9 @@ class Enum(SourceMapping):
self._name = name self._name = name
self._canonical_name = canonical_name self._canonical_name = canonical_name
self._values = values self._values = values
self._min = 0
# The max value of an Enum is the index of the last element
self._max = len(values) - 1
@property @property
def canonical_name(self) -> str: def canonical_name(self) -> str:
@ -22,5 +25,13 @@ class Enum(SourceMapping):
def values(self) -> List[str]: def values(self) -> List[str]:
return self._values return self._values
@property
def min(self) -> int:
return self._min
@property
def max(self) -> int:
return self._max
def __str__(self): def __str__(self):
return self.name return self.name

@ -13,8 +13,9 @@ class TypeInformation(Type):
def __init__(self, c): def __init__(self, c):
# pylint: disable=import-outside-toplevel # pylint: disable=import-outside-toplevel
from slither.core.declarations.contract import Contract from slither.core.declarations.contract import Contract
from slither.core.declarations.enum import Enum
assert isinstance(c, (Contract, ElementaryType)) assert isinstance(c, (Contract, ElementaryType, Enum))
super().__init__() super().__init__()
self._type = c self._type = c

@ -9,6 +9,7 @@ from slither.core.declarations import (
SolidityFunction, SolidityFunction,
Contract, Contract,
) )
from slither.core.declarations.enum import Enum
from slither.core.expressions import ( from slither.core.expressions import (
AssignmentOperationType, AssignmentOperationType,
UnaryOperationType, UnaryOperationType,
@ -403,18 +404,25 @@ class ExpressionToSlithIR(ExpressionVisitor):
assert len(expression.expression.arguments) == 1 assert len(expression.expression.arguments) == 1
val = TemporaryVariable(self._node) val = TemporaryVariable(self._node)
type_expression_found = expression.expression.arguments[0] type_expression_found = expression.expression.arguments[0]
assert isinstance(type_expression_found, ElementaryTypeNameExpression) if isinstance(type_expression_found, ElementaryTypeNameExpression):
type_found = type_expression_found.type type_found = type_expression_found.type
if expression.member_name == "min:": constant_type = type_found
else:
# type(enum).max/min
assert isinstance(type_expression_found, Identifier)
type_found = type_expression_found.value
assert isinstance(type_found, Enum)
constant_type = None
if expression.member_name == "min":
op = Assignment( op = Assignment(
val, val,
Constant(str(type_found.min), type_found), Constant(str(type_found.min), constant_type),
type_found, type_found,
) )
else: else:
op = Assignment( op = Assignment(
val, val,
Constant(str(type_found.max), type_found), Constant(str(type_found.max), constant_type),
type_found, type_found,
) )
self._result.append(op) self._result.append(op)

@ -1,5 +1,3 @@
{ {
"C": { "MinMax": {}
"f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: NEW VARIABLE 1\n\"];\n}\n"
}
} }

@ -1,5 +1,3 @@
{ {
"C": { "MinMax": {}
"f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: NEW VARIABLE 1\n\"];\n}\n"
}
} }

@ -1,5 +1,3 @@
{ {
"C": { "MinMax": {}
"f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: NEW VARIABLE 1\n\"];\n}\n"
}
} }

@ -1,5 +1,3 @@
{ {
"C": { "MinMax": {}
"f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: NEW VARIABLE 1\n\"];\n}\n"
}
} }

@ -1,5 +1,3 @@
{ {
"C": { "MinMax": {}
"f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: NEW VARIABLE 1\n\"];\n}\n"
}
} }

@ -1,5 +1,3 @@
{ {
"C": { "MinMax": {}
"f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: NEW VARIABLE 1\n\"];\n}\n"
}
} }

@ -1,5 +1,3 @@
{ {
"C": { "MinMax": {}
"f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: NEW VARIABLE 1\n\"];\n}\n"
}
} }

@ -1,5 +1,3 @@
{ {
"C": { "MinMax": {}
"f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: NEW VARIABLE 1\n\"];\n}\n"
}
} }

@ -1,5 +1,3 @@
{ {
"C": { "MinMax": {}
"f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: NEW VARIABLE 1\n\"];\n}\n"
}
} }

@ -1,5 +1,3 @@
{ {
"C": { "MinMax": {}
"f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: NEW VARIABLE 1\n\"];\n}\n"
}
} }

@ -1,5 +1,3 @@
{ {
"C": { "MinMax": {}
"f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: NEW VARIABLE 1\n\"];\n}\n"
}
} }

@ -1,5 +1,3 @@
{ {
"C": { "MinMax": {}
"f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: NEW VARIABLE 1\n\"];\n}\n"
}
} }

@ -1,5 +1,3 @@
{ {
"C": { "MinMax": {}
"f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: NEW VARIABLE 1\n\"];\n}\n"
}
} }

@ -1,5 +1,3 @@
{ {
"C": { "MinMax": {}
"f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: NEW VARIABLE 1\n\"];\n}\n"
}
} }

@ -1,5 +1,3 @@
{ {
"C": { "MinMax": {}
"f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: NEW VARIABLE 1\n\"];\n}\n"
}
} }

@ -1,5 +1,3 @@
{ {
"C": { "MinMax": {}
"f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: NEW VARIABLE 1\n\"];\n}\n"
}
} }

@ -1,5 +1,3 @@
{ {
"C": { "MinMax": {}
"f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: NEW VARIABLE 1\n\"];\n}\n"
}
} }

@ -1,5 +1,3 @@
{ {
"C": { "MinMax": {}
"f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: NEW VARIABLE 1\n\"];\n}\n"
}
} }

@ -1,5 +1,3 @@
{ {
"C": { "MinMax": {}
"f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: NEW VARIABLE 1\n\"];\n}\n"
}
} }

@ -1,5 +1,3 @@
{ {
"C": { "MinMax": {}
"f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: NEW VARIABLE 1\n\"];\n}\n"
}
} }

@ -1,5 +1,3 @@
{ {
"C": { "MinMax": {}
"f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: NEW VARIABLE 1\n\"];\n}\n"
}
} }

@ -1,5 +1,3 @@
{ {
"C": { "MinMax": {}
"f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: NEW VARIABLE 1\n\"];\n}\n"
}
} }

@ -1,5 +1,3 @@
{ {
"C": { "MinMax": {}
"f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: NEW VARIABLE 1\n\"];\n}\n"
}
} }

@ -1,5 +1,3 @@
{ {
"C": { "MinMax": {}
"f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: NEW VARIABLE 1\n\"];\n}\n"
}
} }

@ -1,5 +1,3 @@
{ {
"C": { "MinMax": {}
"f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: NEW VARIABLE 1\n\"];\n}\n"
}
} }

@ -1,5 +1,3 @@
{ {
"C": { "MinMax": {}
"f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: NEW VARIABLE 1\n\"];\n}\n"
}
} }

@ -1,5 +1,3 @@
{ {
"C": { "MinMax": {}
"f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: NEW VARIABLE 1\n\"];\n}\n"
}
} }

@ -1,5 +1,3 @@
{ {
"C": { "MinMax": {}
"f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: NEW VARIABLE 1\n\"];\n}\n"
}
} }

@ -1,5 +1,3 @@
{ {
"C": { "MinMax": {}
"f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: NEW VARIABLE 1\n\"];\n}\n"
}
} }

@ -1,5 +1,3 @@
{ {
"C": { "MinMax": {}
"f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: NEW VARIABLE 1\n\"];\n}\n"
}
} }

@ -1,5 +1,3 @@
{ {
"C": { "MinMax": {}
"f()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: NEW VARIABLE 1\n\"];\n}\n"
}
} }

@ -0,0 +1,7 @@
{
"MinMax": {
"constructor()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: EXPRESSION 1\n\"];\n1->2;\n2[label=\"Node Type: EXPRESSION 2\n\"];\n2->3;\n3[label=\"Node Type: EXPRESSION 3\n\"];\n3->4;\n4[label=\"Node Type: EXPRESSION 4\n\"];\n}\n",
"min()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: RETURN 1\n\"];\n}\n",
"max()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: RETURN 1\n\"];\n}\n"
}
}

@ -0,0 +1,7 @@
{
"MinMax": {
"constructor()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: EXPRESSION 1\n\"];\n1->2;\n2[label=\"Node Type: EXPRESSION 2\n\"];\n2->3;\n3[label=\"Node Type: EXPRESSION 3\n\"];\n3->4;\n4[label=\"Node Type: EXPRESSION 4\n\"];\n}\n",
"min()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: RETURN 1\n\"];\n}\n",
"max()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: RETURN 1\n\"];\n}\n"
}
}

@ -0,0 +1,7 @@
{
"MinMax": {
"constructor()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: EXPRESSION 1\n\"];\n1->2;\n2[label=\"Node Type: EXPRESSION 2\n\"];\n2->3;\n3[label=\"Node Type: EXPRESSION 3\n\"];\n3->4;\n4[label=\"Node Type: EXPRESSION 4\n\"];\n}\n",
"min()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: RETURN 1\n\"];\n}\n",
"max()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: RETURN 1\n\"];\n}\n"
}
}

@ -0,0 +1,7 @@
{
"MinMax": {
"constructor()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: EXPRESSION 1\n\"];\n1->2;\n2[label=\"Node Type: EXPRESSION 2\n\"];\n2->3;\n3[label=\"Node Type: EXPRESSION 3\n\"];\n3->4;\n4[label=\"Node Type: EXPRESSION 4\n\"];\n}\n",
"min()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: RETURN 1\n\"];\n}\n",
"max()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: RETURN 1\n\"];\n}\n"
}
}

@ -0,0 +1,7 @@
{
"MinMax": {
"constructor()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: EXPRESSION 1\n\"];\n1->2;\n2[label=\"Node Type: EXPRESSION 2\n\"];\n2->3;\n3[label=\"Node Type: EXPRESSION 3\n\"];\n3->4;\n4[label=\"Node Type: EXPRESSION 4\n\"];\n}\n",
"min()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: RETURN 1\n\"];\n}\n",
"max()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: RETURN 1\n\"];\n}\n"
}
}

@ -0,0 +1,7 @@
{
"MinMax": {
"constructor()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: EXPRESSION 1\n\"];\n1->2;\n2[label=\"Node Type: EXPRESSION 2\n\"];\n2->3;\n3[label=\"Node Type: EXPRESSION 3\n\"];\n3->4;\n4[label=\"Node Type: EXPRESSION 4\n\"];\n}\n",
"min()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: RETURN 1\n\"];\n}\n",
"max()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: RETURN 1\n\"];\n}\n"
}
}

@ -0,0 +1,7 @@
{
"MinMax": {
"constructor()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: EXPRESSION 1\n\"];\n1->2;\n2[label=\"Node Type: EXPRESSION 2\n\"];\n2->3;\n3[label=\"Node Type: EXPRESSION 3\n\"];\n3->4;\n4[label=\"Node Type: EXPRESSION 4\n\"];\n}\n",
"min()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: RETURN 1\n\"];\n}\n",
"max()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: RETURN 1\n\"];\n}\n"
}
}

@ -0,0 +1,7 @@
{
"MinMax": {
"constructor()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: EXPRESSION 1\n\"];\n1->2;\n2[label=\"Node Type: EXPRESSION 2\n\"];\n2->3;\n3[label=\"Node Type: EXPRESSION 3\n\"];\n3->4;\n4[label=\"Node Type: EXPRESSION 4\n\"];\n}\n",
"min()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: RETURN 1\n\"];\n}\n",
"max()": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: RETURN 1\n\"];\n}\n"
}
}

@ -1,9 +1,13 @@
contract C{
function f() public{
uint a = type(uint).max; contract MinMax {
uint a = type(uint).max;
uint b = type(uint).min;
} int constant c = type(int).max;
int constant d = type(int).min;
uint8 immutable i =type(uint8).max;
uint8 immutable j = type(uint8).min;
} }

@ -0,0 +1,29 @@
enum Enum { A, B, C, D }
contract MinMax {
uint a = type(uint).max;
uint b = type(uint).min;
uint c = uint(type(Enum).min);
uint d = uint(type(Enum).max);
int constant e = type(int).max;
int constant f = type(int).min;
uint constant g = uint(type(Enum).max);
uint constant h = uint(type(Enum).min);
uint8 immutable i;
uint8 immutable j;
uint immutable k;
uint immutable l;
constructor() {
i = type(uint8).max;
j = type(uint8).min;
k = uint(type(Enum).max);
l = uint(type(Enum).min);
}
function min() public returns(uint) { return uint(type(Enum).min); }
function max() public returns(uint) { return uint(type(Enum).max); }
}

@ -310,6 +310,10 @@ ALL_TESTS = [
"minmax-0.6.8.sol", "minmax-0.6.8.sol",
make_version(6, 8, 9) + VERSIONS_07 + VERSIONS_08, make_version(6, 8, 9) + VERSIONS_07 + VERSIONS_08,
), ),
Test(
"minmax-0.8.8.sol",
make_version(8, 8, 15),
),
Test("dowhile-0.4.0.sol", VERSIONS_04), Test("dowhile-0.4.0.sol", VERSIONS_04),
Test( Test(
"dowhile-0.4.5.sol", "dowhile-0.4.5.sol",

Loading…
Cancel
Save