Disallow modifier declarations and definitions in interfaces

This commit is contained in:
Kamil Śliwak
2021-08-31 15:25:08 +02:00
committed by Marenz
parent 13691dfbaa
commit d07b796675
11 changed files with 71 additions and 12 deletions
@@ -1114,7 +1114,6 @@ BOOST_AUTO_TEST_CASE(interfaces_and_abstract_contracts)
unique_ptr<CompilerStack> compilerStack = parseAndAnalyzeContracts(R"(
interface I {
event Ev(uint);
modifier m() virtual;
function ext1() external;
function ext2() external;
@@ -1126,6 +1125,8 @@ BOOST_AUTO_TEST_CASE(interfaces_and_abstract_contracts)
}
abstract contract C is J {
modifier m() virtual;
function ext3() external override virtual;
function ext4() external { inr2();}
function inr1() internal virtual;
@@ -1167,7 +1168,7 @@ BOOST_AUTO_TEST_CASE(interfaces_and_abstract_contracts)
{"Entry", "function C.ext4()"},
{"function C.ext4()", "function C.inr2()"},
{"function C.inr2()", "function C.inr1()"},
{"function C.inr2()", "modifier I.m"},
{"function C.inr2()", "modifier C.m"},
}},
{"D", {
{"Entry", "function D.ext1()"},
@@ -0,0 +1,11 @@
contract C {
modifier m { _; }
modifier mv virtual { _; }
}
abstract contract A {
modifier m { _; }
modifier mv virtual { _; }
modifier muv virtual;
}
// ----
@@ -0,0 +1,7 @@
contract C {
modifier mu;
modifier muv virtual;
}
// ----
// TypeError 3656: (0-57): Contract "C" should be marked as abstract.
// TypeError 8063: (17-29): Modifiers without implementation must be marked virtual.
@@ -0,0 +1,12 @@
interface I {
modifier m { _; }
modifier mu;
modifier mv virtual { _; }
modifier muv virtual;
}
// ----
// TypeError 6408: (18-35): Modifiers cannot be defined or declared in interfaces.
// TypeError 6408: (40-52): Modifiers cannot be defined or declared in interfaces.
// TypeError 8063: (40-52): Modifiers without implementation must be marked virtual.
// TypeError 6408: (57-83): Modifiers cannot be defined or declared in interfaces.
// TypeError 6408: (88-109): Modifiers cannot be defined or declared in interfaces.
@@ -0,0 +1,5 @@
library L {
modifier mv virtual { _; }
}
// ----
// TypeError 3275: (16-42): Modifiers in a library cannot be virtual.
@@ -0,0 +1,7 @@
library L {
modifier mu;
modifier muv virtual;
}
// ----
// TypeError 8063: (16-28): Modifiers without implementation must be marked virtual.
// TypeError 3275: (33-54): Modifiers in a library cannot be virtual.
@@ -0,0 +1,4 @@
library L {
modifier m { _; }
}
// ----
@@ -4,3 +4,4 @@ interface I {
}
// ----
// SyntaxError 5842: (16-60): Functions in interfaces cannot have modifiers.
// TypeError 6408: (63-82): Modifiers cannot be defined or declared in interfaces.