Tests, Changelog and updated grammar

This commit is contained in:
hrkrshnn 2020-04-15 15:29:47 +05:30
parent e2e32d372f
commit 48ff9fd4d6
6 changed files with 74 additions and 1 deletions

View File

@ -2,6 +2,7 @@
Language Features:
* Add support for EIP 165 interface identifiers with `type(I).interfaceId`.
* Allow virtual modifiers inside abstract contracts to have empty body.
Compiler Features:

View File

@ -68,7 +68,7 @@ structDefinition
'{' ( variableDeclaration ';' (variableDeclaration ';')* )? '}' ;
modifierDefinition
: 'modifier' identifier parameterList? ( VirtualKeyword | overrideSpecifier )* block ;
: 'modifier' identifier parameterList? ( VirtualKeyword | overrideSpecifier )* ( ';' | block ) ;
functionDefinition
: functionDescriptor parameterList modifierList returnParameters? ( ';' | block ) ;

View File

@ -0,0 +1,17 @@
abstract contract A {
function f() public mod returns (bool r) {
return true;
}
modifier mod virtual;
}
contract C is A {
modifier mod override {
if (false) _;
}
}
// ----
// f() -> false

View File

@ -0,0 +1,14 @@
abstract contract A { modifier mod(uint a) virtual;}
contract B is A { modifier mod(uint a) override { _; } }
abstract contract C {
modifier m virtual;
function f() m public {
}
}
contract D is C {
modifier m override {
_;
}
}

View File

@ -0,0 +1,10 @@
contract A {modifier m virtual;}
abstract contract B {modifier m virtual;}
contract C is B { }
abstract contract D {modifier m;}
// ----
// TypeError: (0-32): Contract "A" should be marked as abstract.
// TypeError: (76-95): Contract "C" should be marked as abstract.
// TypeError: (118-129): Modifiers without implementation must be marked virtual.

View File

@ -0,0 +1,31 @@
abstract contract A {
function foo() public virtual;
function foo(uint x) virtual public returns(uint);
modifier mod() virtual;
}
contract B is A {
function foo(uint x) override public returns(uint) {return x;}
modifier mod() override { _; }
}
contract C is A {
function foo() public override {}
modifier mod() override { _; }
}
contract D is A {
function foo() public override {}
function foo(uint x) override public returns(uint) {return x;}
}
/* No errors */
contract E is A {
function foo() public override {}
function foo(uint x) override public returns(uint) {return x;}
modifier mod() override { _;}
}
// ----
// TypeError: (137-254): Contract "B" should be marked as abstract.
// TypeError: (256-344): Contract "C" should be marked as abstract.
// TypeError: (346-466): Contract "D" should be marked as abstract.