Merge pull request #14205 from ethereum/fixAntlr4

Fix antlr grammar.
This commit is contained in:
Daniel 2023-05-10 12:11:21 +02:00 committed by GitHub
commit 8366bd439b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 17 deletions

View File

@ -20,9 +20,6 @@ Compiler Features:
Bugfixes: Bugfixes:
* ABI: Include events in the ABI that are emitted by a contract but defined outside of it. * ABI: Include events in the ABI that are emitted by a contract but defined outside of it.
* Antlr Grammar: Fix discrepancy with the parser, which allowed octal numbers.
* Antlr Grammar: Fix of a discrepancy with the parser, which allowed numbers followed by an identifier with no whitespace.
* Antlr Grammar: Stricter rules for function definitions. The grammar will no longer accept as valid free functions having specifiers which are exclusive to contract functions.
* Immutables: Disallow initialization of immutables in try/catch statements. * Immutables: Disallow initialization of immutables in try/catch statements.
* SMTChecker: Fix false positives in ternary operators that contain verification targets in its branches, directly or indirectly. * SMTChecker: Fix false positives in ternary operators that contain verification targets in its branches, directly or indirectly.

View File

@ -16,7 +16,7 @@ sourceUnit: (
| contractDefinition | contractDefinition
| interfaceDefinition | interfaceDefinition
| libraryDefinition | libraryDefinition
| freeFunctionDefinition | functionDefinition
| constantVariableDeclaration | constantVariableDeclaration
| structDefinition | structDefinition
| enumDefinition | enumDefinition
@ -85,7 +85,7 @@ inheritanceSpecifier: name=identifierPath arguments=callArgumentList?;
*/ */
contractBodyElement: contractBodyElement:
constructorDefinition constructorDefinition
| contractFunctionDefinition | functionDefinition
| modifierDefinition | modifierDefinition
| fallbackFunctionDefinition | fallbackFunctionDefinition
| receiveFunctionDefinition | receiveFunctionDefinition
@ -152,11 +152,11 @@ stateMutability: Pure | View | Payable;
*/ */
overrideSpecifier: Override (LParen overrides+=identifierPath (Comma overrides+=identifierPath)* RParen)?; overrideSpecifier: Override (LParen overrides+=identifierPath (Comma overrides+=identifierPath)* RParen)?;
/** /**
* The definition of contract, library and interface functions. * The definition of contract, library, interface or free functions.
* Depending on the context in which the function is defined, further restrictions may apply, * Depending on the context in which the function is defined, further restrictions may apply,
* e.g. functions in interfaces have to be unimplemented, i.e. may not contain a body block. * e.g. functions in interfaces have to be unimplemented, i.e. may not contain a body block.
*/ */
contractFunctionDefinition functionDefinition
locals[ locals[
boolean visibilitySet = false, boolean visibilitySet = false,
boolean mutabilitySet = false, boolean mutabilitySet = false,
@ -176,16 +176,6 @@ locals[
(Returns LParen returnParameters=parameterList RParen)? (Returns LParen returnParameters=parameterList RParen)?
(Semicolon | body=block); (Semicolon | body=block);
/**
* The definition of a free function.
*/
freeFunctionDefinition:
Function (identifier | Fallback | Receive)
LParen (arguments=parameterList)? RParen
stateMutability?
(Returns LParen returnParameters=parameterList RParen)?
(Semicolon | body=block);
/** /**
* The definition of a modifier. * The definition of a modifier.
* Note that within the body block of a modifier, the underscore cannot be used as identifier, * Note that within the body block of a modifier, the underscore cannot be used as identifier,