From 1e63615206f3b28e185e05bc9c006b510066fa03 Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 23 Feb 2021 14:13:52 +0100 Subject: [PATCH] Export all events. Update tests. Additional tests Revert changes to the Natspec --- Changelog.md | 7 +- libsolidity/ast/AST.cpp | 21 +- libsolidity/ast/AST.h | 4 + libsolidity/ast/ASTJsonExporter.cpp | 2 + libsolidity/interface/ABI.cpp | 2 +- libsolidity/interface/Natspec.cpp | 53 ++- libsolidity/interface/Natspec.h | 7 + .../ast_compact_json_no_pretty_json/output | 2 +- .../ast_compact_json_with_base_path/output | 3 +- .../combined_json_with_base_path/output | 3 +- test/cmdlineTests/events_in_abi/args | 1 + test/cmdlineTests/events_in_abi/input.sol | 16 + test/cmdlineTests/events_in_abi/output | 59 +++ .../recovery_ast_constructor/output | 3 +- .../recovery_standard_json/output.json | 3 +- .../standard_only_ast_requested/output.json | 3 +- .../ABIJson/event_emited_in_base_contract.sol | 71 +++ ...t_from_aggregated_contract_not_emmited.sol | 42 ++ .../libsolidity/ABIJson/event_inheritance.sol | 62 +++ test/libsolidity/ABIJson/events_indirect.sol | 88 ++++ .../ABIJson/events_repetitions.sol | 45 ++ .../ABIJson/same_event_defined_twice.sol | 61 +++ .../ASTJSON/abstract_contract.json | 3 +- .../ASTJSON/abstract_contract_parseOnly.json | 3 +- test/libsolidity/ASTJSON/address_payable.json | 3 +- .../ASTJSON/address_payable_parseOnly.json | 3 +- test/libsolidity/ASTJSON/array_type_name.json | 3 +- .../ASTJSON/array_type_name_parseOnly.json | 3 +- test/libsolidity/ASTJSON/assembly/call.json | 3 +- .../ASTJSON/assembly/call_parseOnly.json | 3 +- .../ASTJSON/assembly/empty_block.json | 3 +- .../assembly/empty_block_parseOnly.json | 3 +- .../ASTJSON/assembly/function.json | 3 +- .../ASTJSON/assembly/function_parseOnly.json | 3 +- test/libsolidity/ASTJSON/assembly/leave.json | 3 +- .../ASTJSON/assembly/leave_parseOnly.json | 3 +- test/libsolidity/ASTJSON/assembly/loop.json | 3 +- .../ASTJSON/assembly/loop_parseOnly.json | 3 +- .../ASTJSON/assembly/nested_functions.json | 3 +- .../assembly/nested_functions_parseOnly.json | 3 +- .../ASTJSON/assembly/slot_offset.json | 3 +- .../assembly/slot_offset_parseOnly.json | 3 +- .../ASTJSON/assembly/stringlit.json | 3 +- .../ASTJSON/assembly/stringlit_parseOnly.json | 3 +- test/libsolidity/ASTJSON/assembly/switch.json | 3 +- .../ASTJSON/assembly/switch_default.json | 3 +- .../assembly/switch_default_parseOnly.json | 3 +- .../ASTJSON/assembly/switch_parseOnly.json | 3 +- .../ASTJSON/assembly/var_access.json | 3 +- .../assembly/var_access_parseOnly.json | 3 +- .../ast_internal_function_id_export.json | 9 +- .../ASTJSON/base_constructor_call.json | 6 +- .../base_constructor_call_parseOnly.json | 6 +- test/libsolidity/ASTJSON/constructor.json | 3 +- .../ASTJSON/constructor_parseOnly.json | 3 +- .../ASTJSON/contract_dep_order.json | 15 +- .../ASTJSON/contract_dep_order_parseOnly.json | 15 +- test/libsolidity/ASTJSON/documentation.json | 12 +- .../ASTJSON/documentation_local_variable.json | 3 +- ...ocumentation_local_variable_parseOnly.json | 3 +- .../ASTJSON/documentation_on_statements.json | 3 +- ...documentation_on_statements_parseOnly.json | 3 +- .../ASTJSON/documentation_parseOnly.json | 9 +- .../ASTJSON/documentation_triple.json | 3 +- .../documentation_triple_parseOnly.json | 3 +- test/libsolidity/ASTJSON/enum_value.json | 3 +- .../ASTJSON/enum_value_parseOnly.json | 3 +- .../ASTJSON/event_aggregated_contract.json | 398 +++++++++++++++++ .../ASTJSON/event_aggregated_contract.sol | 15 + .../libsolidity/ASTJSON/event_definition.json | 6 +- .../ASTJSON/event_definition_parseOnly.json | 3 +- .../event_emited_in_base_contract.json | 289 +++++++++++++ .../ASTJSON/event_emited_in_base_contract.sol | 9 + .../ASTJSON/event_inheritance.json | 194 +++++++++ .../libsolidity/ASTJSON/event_inheritance.sol | 11 + ...variables_of_internal_types_parseOnly.json | 3 +- .../ASTJSON/fail_after_parsing_parseOnly.json | 3 +- test/libsolidity/ASTJSON/fallback.json | 3 +- ...r.json => fallback_and_receive_ether.json} | 3 +- ...her.sol => fallback_and_receive_ether.sol} | 0 ...fallback_and_receive_ether_parseOnly.json} | 3 +- .../ASTJSON/fallback_parseOnly.json | 3 +- .../libsolidity/ASTJSON/fallback_payable.json | 3 +- .../ASTJSON/fallback_payable_parseOnly.json | 3 +- test/libsolidity/ASTJSON/function_type.json | 3 +- .../ASTJSON/function_type_parseOnly.json | 3 +- test/libsolidity/ASTJSON/indirect_event.json | 319 ++++++++++++++ test/libsolidity/ASTJSON/indirect_event.sol | 11 + .../ASTJSON/indirect_event_parseOnly.json | 228 ++++++++++ .../ASTJSON/inheritance_specifier.json | 6 +- .../inheritance_specifier_parseOnly.json | 6 +- test/libsolidity/ASTJSON/license.json | 3 +- .../ASTJSON/license_parseOnly.json | 3 +- .../long_type_name_binary_operation.json | 3 +- ..._type_name_binary_operation_parseOnly.json | 3 +- .../ASTJSON/long_type_name_identifier.json | 3 +- .../long_type_name_identifier_parseOnly.json | 3 +- test/libsolidity/ASTJSON/mappings.json | 3 +- .../ASTJSON/mappings_parseOnly.json | 3 +- .../ASTJSON/modifier_definition.json | 3 +- .../modifier_definition_parseOnly.json | 3 +- .../ASTJSON/modifier_invocation.json | 3 +- .../modifier_invocation_parseOnly.json | 3 +- test/libsolidity/ASTJSON/mutability.json | 3 +- .../ASTJSON/mutability_parseOnly.json | 3 +- test/libsolidity/ASTJSON/non_utf8.json | 3 +- .../ASTJSON/non_utf8_parseOnly.json | 3 +- .../not_existing_import_parseOnly.json | 3 +- test/libsolidity/ASTJSON/override.json | 9 +- .../ASTJSON/override_parseOnly.json | 9 +- .../ASTJSON/placeholder_statement.json | 3 +- .../placeholder_statement_parseOnly.json | 3 +- test/libsolidity/ASTJSON/receive_ether.json | 3 +- .../ASTJSON/receive_ether_parseOnly.json | 3 +- test/libsolidity/ASTJSON/short_type_name.json | 3 +- .../ASTJSON/short_type_name_parseOnly.json | 3 +- .../ASTJSON/short_type_name_ref.json | 3 +- .../short_type_name_ref_parseOnly.json | 3 +- test/libsolidity/ASTJSON/smoke.json | 3 +- test/libsolidity/ASTJSON/smoke_parseOnly.json | 3 +- test/libsolidity/ASTJSON/source_location.json | 3 +- .../ASTJSON/source_location_parseOnly.json | 3 +- test/libsolidity/ASTJSON/string.json | 3 +- .../libsolidity/ASTJSON/string_parseOnly.json | 3 +- .../ASTJSON/two_base_functions.json | 9 +- .../ASTJSON/two_base_functions_parseOnly.json | 9 +- test/libsolidity/ASTJSON/unicode.json | 3 +- .../ASTJSON/unicode_parseOnly.json | 3 +- test/libsolidity/ASTJSON/used_errors.json | 3 +- .../ASTJSON/used_errors_parseOnly.json | 3 +- .../ASTJSON/userDefinedValueType.json | 3 +- .../userDefinedValueType_parseOnly.json | 3 +- .../ASTJSON/user_defined_operator.json | 3 +- .../ASTJSON/using_for_directive.json | 6 +- .../using_for_directive_parseOnly.json | 6 +- test/libsolidity/ASTJSON/yul_hex_literal.json | 3 +- .../ASTJSON/yul_hex_literal_parseOnly.json | 3 +- test/libsolidity/SolidityNatspecJSON.cpp | 407 +++++++++++++++++- test/libsolidity/StandardCompiler.cpp | 5 +- 139 files changed, 2697 insertions(+), 152 deletions(-) create mode 100644 test/cmdlineTests/events_in_abi/args create mode 100644 test/cmdlineTests/events_in_abi/input.sol create mode 100644 test/cmdlineTests/events_in_abi/output create mode 100644 test/libsolidity/ABIJson/event_emited_in_base_contract.sol create mode 100644 test/libsolidity/ABIJson/event_from_aggregated_contract_not_emmited.sol create mode 100644 test/libsolidity/ABIJson/event_inheritance.sol create mode 100644 test/libsolidity/ABIJson/events_indirect.sol create mode 100644 test/libsolidity/ABIJson/events_repetitions.sol create mode 100644 test/libsolidity/ABIJson/same_event_defined_twice.sol create mode 100644 test/libsolidity/ASTJSON/event_aggregated_contract.json create mode 100644 test/libsolidity/ASTJSON/event_aggregated_contract.sol create mode 100644 test/libsolidity/ASTJSON/event_emited_in_base_contract.json create mode 100644 test/libsolidity/ASTJSON/event_emited_in_base_contract.sol create mode 100644 test/libsolidity/ASTJSON/event_inheritance.json create mode 100644 test/libsolidity/ASTJSON/event_inheritance.sol rename test/libsolidity/ASTJSON/{fallback_and_reveice_ether.json => fallback_and_receive_ether.json} (98%) rename test/libsolidity/ASTJSON/{fallback_and_reveice_ether.sol => fallback_and_receive_ether.sol} (100%) rename test/libsolidity/ASTJSON/{fallback_and_reveice_ether_parseOnly.json => fallback_and_receive_ether_parseOnly.json} (97%) create mode 100644 test/libsolidity/ASTJSON/indirect_event.json create mode 100644 test/libsolidity/ASTJSON/indirect_event.sol create mode 100644 test/libsolidity/ASTJSON/indirect_event_parseOnly.json diff --git a/Changelog.md b/Changelog.md index 531ded9a5..80da2b227 100644 --- a/Changelog.md +++ b/Changelog.md @@ -8,6 +8,7 @@ Compiler Features: * EVM: Support for the EVM Version "Shanghai". * NatSpec: Add support for NatSpec documentation in ``enum`` definitions. * NatSpec: Add support for NatSpec documentation in ``struct`` definitions. + * NatSpec: Include NatSpec from events that are emitted by a contract but defined outside of it in userdoc and devdoc output. * Optimizer: Re-implement simplified version of UnusedAssignEliminator and UnusedStoreEliminator. It can correctly remove some unused assignments in deeply nested loops that were ignored by the old version. * Parser: Unary plus is no longer recognized as a unary operator in the AST and triggers an error at the parsing stage (rather than later during the analysis). * SMTChecker: Properties that are proved safe are now reported explicitly at the end of the analysis. By default, only the number of safe properties is shown. The CLI option ``--model-checker-show-proved-safe`` and the JSON option ``settings.modelChecker.showProvedSafe`` can be enabled to show the full list of safe properties. @@ -16,6 +17,7 @@ Compiler Features: Bugfixes: + * 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. @@ -23,13 +25,14 @@ Bugfixes: AST Changes: - * AST: add the ``internalFunctionID`` field to the AST nodes of functions that may be called via the internal dispatch. These IDs are always generated, but they are only used in via-IR code generation. + * AST: Add the ``internalFunctionID`` field to the AST nodes of functions that may be called via the internal dispatch. These IDs are always generated, but they are only used in via-IR code generation. + * AST: Add the ``usedEvents`` field to ``ContractDefinition`` which contains the AST IDs of all events emitted by the contract as well as all events defined and inherited by the contract. ### 0.8.19 (2023-02-22) Language Features: -* Allow defining custom operators for user-defined value types via ``using {f as +} for T global`` syntax. + * Allow defining custom operators for user-defined value types via ``using {f as +} for T global`` syntax. Compiler Features: diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp index fab1a20f8..833ba739e 100644 --- a/libsolidity/ast/AST.cpp +++ b/libsolidity/ast/AST.cpp @@ -220,9 +220,9 @@ vector const& ContractDefinition::definedInterfaceEvents /// NOTE: this requires the "internal" version of an Event, /// though here internal strictly refers to visibility, /// and not to function encoding (jump vs. call) - auto const& function = e->functionType(true); - solAssert(function, ""); - string eventSignature = function->externalSignature(); + FunctionType const* functionType = e->functionType(true); + solAssert(functionType, ""); + string eventSignature = functionType->externalSignature(); if (eventsSeen.count(eventSignature) == 0) { eventsSeen.insert(eventSignature); @@ -243,6 +243,21 @@ vector const ContractDefinition::usedInterfaceEvents() c ); } +vector ContractDefinition::interfaceEvents(bool _requireCallGraph) const +{ + set result; + for (ContractDefinition const* contract: annotation().linearizedBaseContracts) + result += contract->events(); + solAssert(annotation().creationCallGraph.set() == annotation().deployedCallGraph.set()); + if (_requireCallGraph) + solAssert(annotation().creationCallGraph.set()); + if (annotation().creationCallGraph.set()) + result += usedInterfaceEvents(); + // We could filter out all events that do not have an external interface + // if _requireCallGraph is false. + return util::convertContainer>(std::move(result)); +} + vector ContractDefinition::interfaceErrors(bool _requireCallGraph) const { set result; diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h index d8f6ecd6a..317e95d43 100644 --- a/libsolidity/ast/AST.h +++ b/libsolidity/ast/AST.h @@ -522,6 +522,10 @@ public: std::vector events() const { return filteredNodes(m_subNodes); } std::vector const& definedInterfaceEvents() const; std::vector const usedInterfaceEvents() const; + /// @return all events defined in this contract and its base contracts and all events + /// that are emitted during the execution of the contract. + /// @param _requireCallGraph if false, do not fail if the call graph has not been computed yet. + std::vector interfaceEvents(bool _requireCallGraph = true) const; /// @returns all errors defined in this contract or any base contract /// and all errors referenced during execution. /// @param _requireCallGraph if false, do not fail if the call graph has not been computed yet. diff --git a/libsolidity/ast/ASTJsonExporter.cpp b/libsolidity/ast/ASTJsonExporter.cpp index 84394c76f..ad5a4f9c3 100644 --- a/libsolidity/ast/ASTJsonExporter.cpp +++ b/libsolidity/ast/ASTJsonExporter.cpp @@ -286,6 +286,8 @@ bool ASTJsonExporter::visit(ContractDefinition const& _node) make_pair("abstract", _node.abstract()), make_pair("baseContracts", toJson(_node.baseContracts())), make_pair("contractDependencies", getContainerIds(_node.annotation().contractDependencies | ranges::views::keys)), + // Do not require call graph because the AST is also created for incorrect sources. + make_pair("usedEvents", getContainerIds(_node.interfaceEvents(false))), make_pair("usedErrors", getContainerIds(_node.interfaceErrors(false))), make_pair("nodes", toJson(_node.subNodes())), make_pair("scope", idOrNull(_node.scope())) diff --git a/libsolidity/interface/ABI.cpp b/libsolidity/interface/ABI.cpp index cbfa36122..bfc9c07a5 100644 --- a/libsolidity/interface/ABI.cpp +++ b/libsolidity/interface/ABI.cpp @@ -101,7 +101,7 @@ Json::Value ABI::generate(ContractDefinition const& _contractDef) method["stateMutability"] = stateMutabilityToString(externalFunctionType->stateMutability()); abi.emplace(std::move(method)); } - for (auto const& it: _contractDef.definedInterfaceEvents()) + for (auto const& it: _contractDef.interfaceEvents()) { Json::Value event{Json::objectValue}; event["type"] = "event"; diff --git a/libsolidity/interface/Natspec.cpp b/libsolidity/interface/Natspec.cpp index 27efd1c24..b192dfda1 100644 --- a/libsolidity/interface/Natspec.cpp +++ b/libsolidity/interface/Natspec.cpp @@ -78,8 +78,16 @@ Json::Value Natspec::userDocumentation(ContractDefinition const& _contractDef) doc["methods"][it.second->externalSignature()]["notice"] = value; } - for (auto const& event: _contractDef.definedInterfaceEvents()) + for (auto const& event: uniqueInterfaceEvents(_contractDef)) { + ContractDefinition const* eventOrigin = event->annotation().contract; + solAssert(eventOrigin); + solAssert( + *eventOrigin == _contractDef || + (!eventOrigin->isLibrary() && _contractDef.derivesFrom(*eventOrigin)) || + (eventOrigin->isLibrary() && !_contractDef.derivesFrom(*eventOrigin)) + ); + string value = extractDoc(event->annotation().docTags, "notice"); if (!value.empty()) doc["events"][event->functionType(true)->externalSignature()]["notice"] = value; @@ -168,10 +176,18 @@ Json::Value Natspec::devDocumentation(ContractDefinition const& _contractDef) )); } - for (auto const& event: _contractDef.definedInterfaceEvents()) + for (auto const& event: uniqueInterfaceEvents(_contractDef)) if (auto devDoc = devDocumentation(event->annotation().docTags); !devDoc.empty()) + { + ContractDefinition const* eventOrigin = event->annotation().contract; + solAssert(eventOrigin); + solAssert( + *eventOrigin == _contractDef || + (!eventOrigin->isLibrary() && _contractDef.derivesFrom(*eventOrigin)) || + (eventOrigin->isLibrary() && !_contractDef.derivesFrom(*eventOrigin)) + ); doc["events"][event->functionType(true)->externalSignature()] = devDoc; - + } for (auto const& error: _contractDef.interfaceErrors()) if (auto devDoc = devDocumentation(error->annotation().docTags); !devDoc.empty()) doc["errors"][error->functionType(true)->externalSignature()].append(devDoc); @@ -255,3 +271,34 @@ Json::Value Natspec::devDocumentation(std::multimap const& return json; } + +vector Natspec::uniqueInterfaceEvents(ContractDefinition const& _contract) +{ + auto eventSignature = [](EventDefinition const* _event) -> string { + FunctionType const* functionType = _event->functionType(true); + solAssert(functionType, ""); + return functionType->externalSignature(); + }; + auto compareBySignature = + [&](EventDefinition const* _lhs, EventDefinition const* _rhs) -> bool { + return eventSignature(_lhs) < eventSignature(_rhs); + }; + + set uniqueEvents{compareBySignature}; + // Insert events defined in the contract first so that in case of a conflict + // they're the ones that get selected. + uniqueEvents += _contract.definedInterfaceEvents(); + + set filteredUsedEvents{compareBySignature}; + set usedSignatures; + for (EventDefinition const* event: _contract.usedInterfaceEvents()) + { + auto&& [eventIt, eventInserted] = filteredUsedEvents.insert(event); + auto&& [signatureIt, signatureInserted] = usedSignatures.insert(eventSignature(event)); + if (!signatureInserted) + filteredUsedEvents.erase(eventIt); + } + + uniqueEvents += filteredUsedEvents; + return util::convertContainer>(std::move(uniqueEvents)); +} diff --git a/libsolidity/interface/Natspec.h b/libsolidity/interface/Natspec.h index bbf624384..e75485097 100644 --- a/libsolidity/interface/Natspec.h +++ b/libsolidity/interface/Natspec.h @@ -72,6 +72,13 @@ private: /// @return A JSON representation /// of a method's return notice documentation static Json::Value extractReturnParameterDocs(std::multimap const& _tags, std::vector const& _returnParameterNames); + + /// Temporary function until https://github.com/ethereum/solidity/issues/11114 is implemented. + /// @return all events defined in the contract and its base contracts and all events + /// that are emitted during the execution of the contract, but allowing only unique signatures. + /// In case of conflict between a library event and a contract one, selects the latter + /// In case of conflict between two library events, none is selected + static std::vector uniqueInterfaceEvents(ContractDefinition const& _contract); }; } diff --git a/test/cmdlineTests/ast_compact_json_no_pretty_json/output b/test/cmdlineTests/ast_compact_json_no_pretty_json/output index abdc17125..fb79fd524 100644 --- a/test/cmdlineTests/ast_compact_json_no_pretty_json/output +++ b/test/cmdlineTests/ast_compact_json_no_pretty_json/output @@ -2,4 +2,4 @@ JSON AST (compact format): ======= ast_compact_json_no_pretty_json/input.sol ======= -{"absolutePath":"ast_compact_json_no_pretty_json/input.sol","exportedSymbols":{"C":[2]},"id":3,"license":"GPL-3.0","nodeType":"SourceUnit","nodes":[{"id":1,"literals":["solidity",">=","0.0"],"nodeType":"PragmaDirective","src":"36:22:0"},{"abstract":false,"baseContracts":[],"canonicalName":"C","contractDependencies":[],"contractKind":"contract","fullyImplemented":true,"id":2,"linearizedBaseContracts":[2],"name":"C","nameLocation":"69:1:0","nodeType":"ContractDefinition","nodes":[],"scope":3,"src":"60:13:0","usedErrors":[]}],"src":"36:38:0"} +{"absolutePath":"ast_compact_json_no_pretty_json/input.sol","exportedSymbols":{"C":[2]},"id":3,"license":"GPL-3.0","nodeType":"SourceUnit","nodes":[{"id":1,"literals":["solidity",">=","0.0"],"nodeType":"PragmaDirective","src":"36:22:0"},{"abstract":false,"baseContracts":[],"canonicalName":"C","contractDependencies":[],"contractKind":"contract","fullyImplemented":true,"id":2,"linearizedBaseContracts":[2],"name":"C","nameLocation":"69:1:0","nodeType":"ContractDefinition","nodes":[],"scope":3,"src":"60:13:0","usedErrors":[],"usedEvents":[]}],"src":"36:38:0"} diff --git a/test/cmdlineTests/ast_compact_json_with_base_path/output b/test/cmdlineTests/ast_compact_json_with_base_path/output index 6404ef3bd..5c5c6ffd5 100644 --- a/test/cmdlineTests/ast_compact_json_with_base_path/output +++ b/test/cmdlineTests/ast_compact_json_with_base_path/output @@ -45,7 +45,8 @@ JSON AST (compact format): "nodes": [], "scope": 6, "src": "60:13:0", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "36:38:0" diff --git a/test/cmdlineTests/combined_json_with_base_path/output b/test/cmdlineTests/combined_json_with_base_path/output index 9acdea553..127773320 100644 --- a/test/cmdlineTests/combined_json_with_base_path/output +++ b/test/cmdlineTests/combined_json_with_base_path/output @@ -56,7 +56,8 @@ "nodes": [], "scope": 6, "src": "60:13:0", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "36:38:0" diff --git a/test/cmdlineTests/events_in_abi/args b/test/cmdlineTests/events_in_abi/args new file mode 100644 index 000000000..d27d3ef12 --- /dev/null +++ b/test/cmdlineTests/events_in_abi/args @@ -0,0 +1 @@ +--abi --pretty-json --json-indent 4 diff --git a/test/cmdlineTests/events_in_abi/input.sol b/test/cmdlineTests/events_in_abi/input.sol new file mode 100644 index 000000000..a0d91d2e2 --- /dev/null +++ b/test/cmdlineTests/events_in_abi/input.sol @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-3.0 +pragma solidity >=0.0; +library L { + event e1(uint b); +} + +function f() { + emit L.e1(5); +} + +contract C { + event e1(uint indexed a); + function g() public { + f(); + } +} diff --git a/test/cmdlineTests/events_in_abi/output b/test/cmdlineTests/events_in_abi/output new file mode 100644 index 000000000..6c18a1752 --- /dev/null +++ b/test/cmdlineTests/events_in_abi/output @@ -0,0 +1,59 @@ + +======= events_in_abi/input.sol:C ======= +Contract JSON ABI +[ + { + "anonymous": false, + "inputs": + [ + { + "indexed": false, + "internalType": "uint256", + "name": "b", + "type": "uint256" + } + ], + "name": "e1", + "type": "event" + }, + { + "anonymous": false, + "inputs": + [ + { + "indexed": true, + "internalType": "uint256", + "name": "a", + "type": "uint256" + } + ], + "name": "e1", + "type": "event" + }, + { + "inputs": [], + "name": "g", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] + +======= events_in_abi/input.sol:L ======= +Contract JSON ABI +[ + { + "anonymous": false, + "inputs": + [ + { + "indexed": false, + "internalType": "uint256", + "name": "b", + "type": "uint256" + } + ], + "name": "e1", + "type": "event" + } +] diff --git a/test/cmdlineTests/recovery_ast_constructor/output b/test/cmdlineTests/recovery_ast_constructor/output index 33c07b4c1..fd92fb7fa 100644 --- a/test/cmdlineTests/recovery_ast_constructor/output +++ b/test/cmdlineTests/recovery_ast_constructor/output @@ -180,7 +180,8 @@ JSON AST (compact format): ], "scope": 19, "src": "62:399:0", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "36:426:0" diff --git a/test/cmdlineTests/recovery_standard_json/output.json b/test/cmdlineTests/recovery_standard_json/output.json index 68415ac0c..110b70616 100644 --- a/test/cmdlineTests/recovery_standard_json/output.json +++ b/test/cmdlineTests/recovery_standard_json/output.json @@ -90,7 +90,8 @@ "nodes": [], "scope": 4, "src": "59:35:0", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "36:84:0" diff --git a/test/cmdlineTests/standard_only_ast_requested/output.json b/test/cmdlineTests/standard_only_ast_requested/output.json index 4caa8a764..6ecac5ca3 100644 --- a/test/cmdlineTests/standard_only_ast_requested/output.json +++ b/test/cmdlineTests/standard_only_ast_requested/output.json @@ -85,7 +85,8 @@ ], "scope": 7, "src": "59:42:0", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "36:65:0" diff --git a/test/libsolidity/ABIJson/event_emited_in_base_contract.sol b/test/libsolidity/ABIJson/event_emited_in_base_contract.sol new file mode 100644 index 000000000..f9c3d2019 --- /dev/null +++ b/test/libsolidity/ABIJson/event_emited_in_base_contract.sol @@ -0,0 +1,71 @@ +library L { event E(uint8); } + +contract B { + constructor() { + emit L.E(0); + } +} + +contract C is B {} + +// ---- +// :B +// [ +// { +// "inputs": [], +// "stateMutability": "nonpayable", +// "type": "constructor" +// }, +// { +// "anonymous": false, +// "inputs": +// [ +// { +// "indexed": false, +// "internalType": "uint8", +// "name": "", +// "type": "uint8" +// } +// ], +// "name": "E", +// "type": "event" +// } +// ] +// +// +// :C +// [ +// { +// "anonymous": false, +// "inputs": +// [ +// { +// "indexed": false, +// "internalType": "uint8", +// "name": "", +// "type": "uint8" +// } +// ], +// "name": "E", +// "type": "event" +// } +// ] +// +// +// :L +// [ +// { +// "anonymous": false, +// "inputs": +// [ +// { +// "indexed": false, +// "internalType": "uint8", +// "name": "", +// "type": "uint8" +// } +// ], +// "name": "E", +// "type": "event" +// } +// ] diff --git a/test/libsolidity/ABIJson/event_from_aggregated_contract_not_emmited.sol b/test/libsolidity/ABIJson/event_from_aggregated_contract_not_emmited.sol new file mode 100644 index 000000000..6a930589d --- /dev/null +++ b/test/libsolidity/ABIJson/event_from_aggregated_contract_not_emmited.sol @@ -0,0 +1,42 @@ +contract C { + event e(); + function f() public { + emit e(); + } +} + +contract D { + C c; + constructor() { + c = new C(); + c.f(); + } +} + +// ---- +// :C +// [ +// { +// "anonymous": false, +// "inputs": [], +// "name": "e", +// "type": "event" +// }, +// { +// "inputs": [], +// "name": "f", +// "outputs": [], +// "stateMutability": "nonpayable", +// "type": "function" +// } +// ] +// +// +// :D +// [ +// { +// "inputs": [], +// "stateMutability": "nonpayable", +// "type": "constructor" +// } +// ] diff --git a/test/libsolidity/ABIJson/event_inheritance.sol b/test/libsolidity/ABIJson/event_inheritance.sol new file mode 100644 index 000000000..e4a8aeea4 --- /dev/null +++ b/test/libsolidity/ABIJson/event_inheritance.sol @@ -0,0 +1,62 @@ +interface B { + event EB(); +} + +contract C is B { + event EC(); +} + +contract D is C { + event ED(); +} + +// ---- +// :B +// [ +// { +// "anonymous": false, +// "inputs": [], +// "name": "EB", +// "type": "event" +// } +// ] +// +// +// :C +// [ +// { +// "anonymous": false, +// "inputs": [], +// "name": "EB", +// "type": "event" +// }, +// { +// "anonymous": false, +// "inputs": [], +// "name": "EC", +// "type": "event" +// } +// ] +// +// +// :D +// [ +// { +// "anonymous": false, +// "inputs": [], +// "name": "EB", +// "type": "event" +// }, +// { +// "anonymous": false, +// "inputs": [], +// "name": "EC", +// "type": "event" +// }, +// { +// "anonymous": false, +// "inputs": [], +// "name": "ED", +// "type": "event" +// } +// ] diff --git a/test/libsolidity/ABIJson/events_indirect.sol b/test/libsolidity/ABIJson/events_indirect.sol new file mode 100644 index 000000000..86368028c --- /dev/null +++ b/test/libsolidity/ABIJson/events_indirect.sol @@ -0,0 +1,88 @@ +library L { + event e1(uint b); + event e2(); + event e2(uint a); + event e3() anonymous; +} +contract test { + function f() public { + emit L.e1(1); + emit L.e3(); + } +} +// ---- +// :L +// [ +// { +// "anonymous": false, +// "inputs": +// [ +// { +// "indexed": false, +// "internalType": "uint256", +// "name": "b", +// "type": "uint256" +// } +// ], +// "name": "e1", +// "type": "event" +// }, +// { +// "anonymous": false, +// "inputs": [], +// "name": "e2", +// "type": "event" +// }, +// { +// "anonymous": false, +// "inputs": +// [ +// { +// "indexed": false, +// "internalType": "uint256", +// "name": "a", +// "type": "uint256" +// } +// ], +// "name": "e2", +// "type": "event" +// }, +// { +// "anonymous": true, +// "inputs": [], +// "name": "e3", +// "type": "event" +// } +// ] +// +// +// :test +// [ +// { +// "anonymous": false, +// "inputs": +// [ +// { +// "indexed": false, +// "internalType": "uint256", +// "name": "b", +// "type": "uint256" +// } +// ], +// "name": "e1", +// "type": "event" +// }, +// { +// "anonymous": true, +// "inputs": [], +// "name": "e3", +// "type": "event" +// }, +// { +// "inputs": [], +// "name": "f", +// "outputs": [], +// "stateMutability": "nonpayable", +// "type": "function" +// } +// ] diff --git a/test/libsolidity/ABIJson/events_repetitions.sol b/test/libsolidity/ABIJson/events_repetitions.sol new file mode 100644 index 000000000..8dd980a6a --- /dev/null +++ b/test/libsolidity/ABIJson/events_repetitions.sol @@ -0,0 +1,45 @@ +library L { + event e(); +} +contract C { + constructor() { + emit L.e(); + } + function f() public { + emit L.e(); + } +} + +// ---- +// :C +// [ +// { +// "inputs": [], +// "stateMutability": "nonpayable", +// "type": "constructor" +// }, +// { +// "anonymous": false, +// "inputs": [], +// "name": "e", +// "type": "event" +// }, +// { +// "inputs": [], +// "name": "f", +// "outputs": [], +// "stateMutability": "nonpayable", +// "type": "function" +// } +// ] +// +// +// :L +// [ +// { +// "anonymous": false, +// "inputs": [], +// "name": "e", +// "type": "event" +// } +// ] diff --git a/test/libsolidity/ABIJson/same_event_defined_twice.sol b/test/libsolidity/ABIJson/same_event_defined_twice.sol new file mode 100644 index 000000000..9a65e61d6 --- /dev/null +++ b/test/libsolidity/ABIJson/same_event_defined_twice.sol @@ -0,0 +1,61 @@ +library L1 { event e(); } +library L2 { event e(); } +contract C { + constructor() { + emit L1.e(); + } + function f() public { + emit L2.e(); + } +} + +// ---- +// :C +// [ +// { +// "inputs": [], +// "stateMutability": "nonpayable", +// "type": "constructor" +// }, +// { +// "anonymous": false, +// "inputs": [], +// "name": "e", +// "type": "event" +// }, +// { +// "anonymous": false, +// "inputs": [], +// "name": "e", +// "type": "event" +// }, +// { +// "inputs": [], +// "name": "f", +// "outputs": [], +// "stateMutability": "nonpayable", +// "type": "function" +// } +// ] +// +// +// :L1 +// [ +// { +// "anonymous": false, +// "inputs": [], +// "name": "e", +// "type": "event" +// } +// ] +// +// +// :L2 +// [ +// { +// "anonymous": false, +// "inputs": [], +// "name": "e", +// "type": "event" +// } +// ] diff --git a/test/libsolidity/ASTJSON/abstract_contract.json b/test/libsolidity/ASTJSON/abstract_contract.json index 168433eb9..48c20b435 100644 --- a/test/libsolidity/ASTJSON/abstract_contract.json +++ b/test/libsolidity/ASTJSON/abstract_contract.json @@ -66,7 +66,8 @@ ], "scope": 6, "src": "0:43:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:44:1" diff --git a/test/libsolidity/ASTJSON/abstract_contract_parseOnly.json b/test/libsolidity/ASTJSON/abstract_contract_parseOnly.json index 51dd803a3..d9ba04e6c 100644 --- a/test/libsolidity/ASTJSON/abstract_contract_parseOnly.json +++ b/test/libsolidity/ASTJSON/abstract_contract_parseOnly.json @@ -50,7 +50,8 @@ } ], "src": "0:43:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:44:1" diff --git a/test/libsolidity/ASTJSON/address_payable.json b/test/libsolidity/ASTJSON/address_payable.json index 83ba2c6d7..adf79823e 100644 --- a/test/libsolidity/ASTJSON/address_payable.json +++ b/test/libsolidity/ASTJSON/address_payable.json @@ -571,7 +571,8 @@ ], "scope": 40, "src": "0:258:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:259:1" diff --git a/test/libsolidity/ASTJSON/address_payable_parseOnly.json b/test/libsolidity/ASTJSON/address_payable_parseOnly.json index 9d095dc68..02b809cc9 100644 --- a/test/libsolidity/ASTJSON/address_payable_parseOnly.json +++ b/test/libsolidity/ASTJSON/address_payable_parseOnly.json @@ -378,7 +378,8 @@ } ], "src": "0:258:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:259:1" diff --git a/test/libsolidity/ASTJSON/array_type_name.json b/test/libsolidity/ASTJSON/array_type_name.json index c1bcaa985..1cd97e176 100644 --- a/test/libsolidity/ASTJSON/array_type_name.json +++ b/test/libsolidity/ASTJSON/array_type_name.json @@ -72,7 +72,8 @@ ], "scope": 5, "src": "0:24:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:25:1" diff --git a/test/libsolidity/ASTJSON/array_type_name_parseOnly.json b/test/libsolidity/ASTJSON/array_type_name_parseOnly.json index 4248a3f98..1e0b72ca0 100644 --- a/test/libsolidity/ASTJSON/array_type_name_parseOnly.json +++ b/test/libsolidity/ASTJSON/array_type_name_parseOnly.json @@ -45,7 +45,8 @@ } ], "src": "0:24:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:25:1" diff --git a/test/libsolidity/ASTJSON/assembly/call.json b/test/libsolidity/ASTJSON/assembly/call.json index c6e0561ed..7081d2f98 100644 --- a/test/libsolidity/ASTJSON/assembly/call.json +++ b/test/libsolidity/ASTJSON/assembly/call.json @@ -164,7 +164,8 @@ ], "scope": 7, "src": "0:98:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:99:1" diff --git a/test/libsolidity/ASTJSON/assembly/call_parseOnly.json b/test/libsolidity/ASTJSON/assembly/call_parseOnly.json index 27d6ac07d..1a9dc74a2 100644 --- a/test/libsolidity/ASTJSON/assembly/call_parseOnly.json +++ b/test/libsolidity/ASTJSON/assembly/call_parseOnly.json @@ -148,7 +148,8 @@ } ], "src": "0:98:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:99:1" diff --git a/test/libsolidity/ASTJSON/assembly/empty_block.json b/test/libsolidity/ASTJSON/assembly/empty_block.json index 19779b076..05dc8c0c0 100644 --- a/test/libsolidity/ASTJSON/assembly/empty_block.json +++ b/test/libsolidity/ASTJSON/assembly/empty_block.json @@ -89,7 +89,8 @@ ], "scope": 7, "src": "0:75:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:76:1" diff --git a/test/libsolidity/ASTJSON/assembly/empty_block_parseOnly.json b/test/libsolidity/ASTJSON/assembly/empty_block_parseOnly.json index 8b07db893..4a1d1f614 100644 --- a/test/libsolidity/ASTJSON/assembly/empty_block_parseOnly.json +++ b/test/libsolidity/ASTJSON/assembly/empty_block_parseOnly.json @@ -73,7 +73,8 @@ } ], "src": "0:75:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:76:1" diff --git a/test/libsolidity/ASTJSON/assembly/function.json b/test/libsolidity/ASTJSON/assembly/function.json index e528baa4c..d8822183c 100644 --- a/test/libsolidity/ASTJSON/assembly/function.json +++ b/test/libsolidity/ASTJSON/assembly/function.json @@ -151,7 +151,8 @@ ], "scope": 7, "src": "0:112:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:113:1" diff --git a/test/libsolidity/ASTJSON/assembly/function_parseOnly.json b/test/libsolidity/ASTJSON/assembly/function_parseOnly.json index f89a2fa6d..8115fc0ae 100644 --- a/test/libsolidity/ASTJSON/assembly/function_parseOnly.json +++ b/test/libsolidity/ASTJSON/assembly/function_parseOnly.json @@ -135,7 +135,8 @@ } ], "src": "0:112:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:113:1" diff --git a/test/libsolidity/ASTJSON/assembly/leave.json b/test/libsolidity/ASTJSON/assembly/leave.json index eefc5105f..23ac98ccb 100644 --- a/test/libsolidity/ASTJSON/assembly/leave.json +++ b/test/libsolidity/ASTJSON/assembly/leave.json @@ -101,7 +101,8 @@ ], "scope": 7, "src": "0:90:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:91:1" diff --git a/test/libsolidity/ASTJSON/assembly/leave_parseOnly.json b/test/libsolidity/ASTJSON/assembly/leave_parseOnly.json index ba8b54507..215266456 100644 --- a/test/libsolidity/ASTJSON/assembly/leave_parseOnly.json +++ b/test/libsolidity/ASTJSON/assembly/leave_parseOnly.json @@ -85,7 +85,8 @@ } ], "src": "0:90:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:91:1" diff --git a/test/libsolidity/ASTJSON/assembly/loop.json b/test/libsolidity/ASTJSON/assembly/loop.json index 8a887a80f..7e684b4a3 100644 --- a/test/libsolidity/ASTJSON/assembly/loop.json +++ b/test/libsolidity/ASTJSON/assembly/loop.json @@ -164,7 +164,8 @@ ], "scope": 7, "src": "0:118:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:119:1" diff --git a/test/libsolidity/ASTJSON/assembly/loop_parseOnly.json b/test/libsolidity/ASTJSON/assembly/loop_parseOnly.json index 8ee936747..934afdf42 100644 --- a/test/libsolidity/ASTJSON/assembly/loop_parseOnly.json +++ b/test/libsolidity/ASTJSON/assembly/loop_parseOnly.json @@ -148,7 +148,8 @@ } ], "src": "0:118:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:119:1" diff --git a/test/libsolidity/ASTJSON/assembly/nested_functions.json b/test/libsolidity/ASTJSON/assembly/nested_functions.json index 41a18a1d0..881e7456f 100644 --- a/test/libsolidity/ASTJSON/assembly/nested_functions.json +++ b/test/libsolidity/ASTJSON/assembly/nested_functions.json @@ -169,7 +169,8 @@ ], "scope": 9, "src": "0:154:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:155:1" diff --git a/test/libsolidity/ASTJSON/assembly/nested_functions_parseOnly.json b/test/libsolidity/ASTJSON/assembly/nested_functions_parseOnly.json index f5f554608..a9ac0965a 100644 --- a/test/libsolidity/ASTJSON/assembly/nested_functions_parseOnly.json +++ b/test/libsolidity/ASTJSON/assembly/nested_functions_parseOnly.json @@ -135,7 +135,8 @@ } ], "src": "0:154:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:155:1" diff --git a/test/libsolidity/ASTJSON/assembly/slot_offset.json b/test/libsolidity/ASTJSON/assembly/slot_offset.json index 1e6fe1447..e61125cbd 100644 --- a/test/libsolidity/ASTJSON/assembly/slot_offset.json +++ b/test/libsolidity/ASTJSON/assembly/slot_offset.json @@ -245,7 +245,8 @@ ], "scope": 13, "src": "0:148:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:149:1" diff --git a/test/libsolidity/ASTJSON/assembly/slot_offset_parseOnly.json b/test/libsolidity/ASTJSON/assembly/slot_offset_parseOnly.json index 4135bb343..ccf9c53fe 100644 --- a/test/libsolidity/ASTJSON/assembly/slot_offset_parseOnly.json +++ b/test/libsolidity/ASTJSON/assembly/slot_offset_parseOnly.json @@ -189,7 +189,8 @@ } ], "src": "0:148:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:149:1" diff --git a/test/libsolidity/ASTJSON/assembly/stringlit.json b/test/libsolidity/ASTJSON/assembly/stringlit.json index 64777e947..33211190e 100644 --- a/test/libsolidity/ASTJSON/assembly/stringlit.json +++ b/test/libsolidity/ASTJSON/assembly/stringlit.json @@ -106,7 +106,8 @@ ], "scope": 7, "src": "0:82:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:83:1" diff --git a/test/libsolidity/ASTJSON/assembly/stringlit_parseOnly.json b/test/libsolidity/ASTJSON/assembly/stringlit_parseOnly.json index e82999a78..dd4e1d061 100644 --- a/test/libsolidity/ASTJSON/assembly/stringlit_parseOnly.json +++ b/test/libsolidity/ASTJSON/assembly/stringlit_parseOnly.json @@ -90,7 +90,8 @@ } ], "src": "0:82:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:83:1" diff --git a/test/libsolidity/ASTJSON/assembly/switch.json b/test/libsolidity/ASTJSON/assembly/switch.json index f78699ef6..26874da0e 100644 --- a/test/libsolidity/ASTJSON/assembly/switch.json +++ b/test/libsolidity/ASTJSON/assembly/switch.json @@ -197,7 +197,8 @@ ], "scope": 7, "src": "0:198:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:199:1" diff --git a/test/libsolidity/ASTJSON/assembly/switch_default.json b/test/libsolidity/ASTJSON/assembly/switch_default.json index 16e1f1bf4..d472ea018 100644 --- a/test/libsolidity/ASTJSON/assembly/switch_default.json +++ b/test/libsolidity/ASTJSON/assembly/switch_default.json @@ -128,7 +128,8 @@ ], "scope": 7, "src": "0:102:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:103:1" diff --git a/test/libsolidity/ASTJSON/assembly/switch_default_parseOnly.json b/test/libsolidity/ASTJSON/assembly/switch_default_parseOnly.json index 4539f8596..e4a3e1b40 100644 --- a/test/libsolidity/ASTJSON/assembly/switch_default_parseOnly.json +++ b/test/libsolidity/ASTJSON/assembly/switch_default_parseOnly.json @@ -112,7 +112,8 @@ } ], "src": "0:102:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:103:1" diff --git a/test/libsolidity/ASTJSON/assembly/switch_parseOnly.json b/test/libsolidity/ASTJSON/assembly/switch_parseOnly.json index 54d38b638..d7392a8c8 100644 --- a/test/libsolidity/ASTJSON/assembly/switch_parseOnly.json +++ b/test/libsolidity/ASTJSON/assembly/switch_parseOnly.json @@ -181,7 +181,8 @@ } ], "src": "0:198:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:199:1" diff --git a/test/libsolidity/ASTJSON/assembly/var_access.json b/test/libsolidity/ASTJSON/assembly/var_access.json index 9cddf4460..c93667df2 100644 --- a/test/libsolidity/ASTJSON/assembly/var_access.json +++ b/test/libsolidity/ASTJSON/assembly/var_access.json @@ -155,7 +155,8 @@ ], "scope": 10, "src": "0:95:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:96:1" diff --git a/test/libsolidity/ASTJSON/assembly/var_access_parseOnly.json b/test/libsolidity/ASTJSON/assembly/var_access_parseOnly.json index 1444a3da1..b56324944 100644 --- a/test/libsolidity/ASTJSON/assembly/var_access_parseOnly.json +++ b/test/libsolidity/ASTJSON/assembly/var_access_parseOnly.json @@ -121,7 +121,8 @@ } ], "src": "0:95:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:96:1" diff --git a/test/libsolidity/ASTJSON/ast_internal_function_id_export.json b/test/libsolidity/ASTJSON/ast_internal_function_id_export.json index 02da00d6d..3e6e67bdd 100644 --- a/test/libsolidity/ASTJSON/ast_internal_function_id_export.json +++ b/test/libsolidity/ASTJSON/ast_internal_function_id_export.json @@ -568,7 +568,8 @@ ], "scope": 142, "src": "60:299:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] }, { "abstract": false, @@ -1374,7 +1375,8 @@ ], "scope": 142, "src": "360:462:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] }, { "abstract": false, @@ -1533,7 +1535,8 @@ ], "scope": 142, "src": "823:85:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:909:1" diff --git a/test/libsolidity/ASTJSON/base_constructor_call.json b/test/libsolidity/ASTJSON/base_constructor_call.json index 774981fa9..2c3c68c40 100644 --- a/test/libsolidity/ASTJSON/base_constructor_call.json +++ b/test/libsolidity/ASTJSON/base_constructor_call.json @@ -102,7 +102,8 @@ ], "scope": 18, "src": "0:35:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] }, { "abstract": false, @@ -219,7 +220,8 @@ ], "scope": 18, "src": "36:41:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:78:1" diff --git a/test/libsolidity/ASTJSON/base_constructor_call_parseOnly.json b/test/libsolidity/ASTJSON/base_constructor_call_parseOnly.json index 8af0c0b2c..730a05178 100644 --- a/test/libsolidity/ASTJSON/base_constructor_call_parseOnly.json +++ b/test/libsolidity/ASTJSON/base_constructor_call_parseOnly.json @@ -73,7 +73,8 @@ } ], "src": "0:35:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] }, { "abstract": false, @@ -169,7 +170,8 @@ } ], "src": "36:41:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:78:1" diff --git a/test/libsolidity/ASTJSON/constructor.json b/test/libsolidity/ASTJSON/constructor.json index 9ac4ac9c8..53e622b5d 100644 --- a/test/libsolidity/ASTJSON/constructor.json +++ b/test/libsolidity/ASTJSON/constructor.json @@ -66,7 +66,8 @@ ], "scope": 6, "src": "0:34:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:35:1" diff --git a/test/libsolidity/ASTJSON/constructor_parseOnly.json b/test/libsolidity/ASTJSON/constructor_parseOnly.json index 19d647058..9b1d4cfc4 100644 --- a/test/libsolidity/ASTJSON/constructor_parseOnly.json +++ b/test/libsolidity/ASTJSON/constructor_parseOnly.json @@ -50,7 +50,8 @@ } ], "src": "0:34:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:35:1" diff --git a/test/libsolidity/ASTJSON/contract_dep_order.json b/test/libsolidity/ASTJSON/contract_dep_order.json index 83865d7d4..67eff600b 100644 --- a/test/libsolidity/ASTJSON/contract_dep_order.json +++ b/test/libsolidity/ASTJSON/contract_dep_order.json @@ -45,7 +45,8 @@ "nodes": [], "scope": 14, "src": "0:14:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] }, { "abstract": false, @@ -85,7 +86,8 @@ "nodes": [], "scope": 14, "src": "15:19:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] }, { "abstract": false, @@ -126,7 +128,8 @@ "nodes": [], "scope": 14, "src": "35:19:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] }, { "abstract": false, @@ -168,7 +171,8 @@ "nodes": [], "scope": 14, "src": "55:19:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] }, { "abstract": false, @@ -211,7 +215,8 @@ "nodes": [], "scope": 14, "src": "75:19:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:95:1" diff --git a/test/libsolidity/ASTJSON/contract_dep_order_parseOnly.json b/test/libsolidity/ASTJSON/contract_dep_order_parseOnly.json index 2c8bdc745..ba8c377cf 100644 --- a/test/libsolidity/ASTJSON/contract_dep_order_parseOnly.json +++ b/test/libsolidity/ASTJSON/contract_dep_order_parseOnly.json @@ -15,7 +15,8 @@ "nodeType": "ContractDefinition", "nodes": [], "src": "0:14:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] }, { "abstract": false, @@ -46,7 +47,8 @@ "nodeType": "ContractDefinition", "nodes": [], "src": "15:19:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] }, { "abstract": false, @@ -77,7 +79,8 @@ "nodeType": "ContractDefinition", "nodes": [], "src": "35:19:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] }, { "abstract": false, @@ -108,7 +111,8 @@ "nodeType": "ContractDefinition", "nodes": [], "src": "55:19:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] }, { "abstract": false, @@ -139,7 +143,8 @@ "nodeType": "ContractDefinition", "nodes": [], "src": "75:19:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:95:1" diff --git a/test/libsolidity/ASTJSON/documentation.json b/test/libsolidity/ASTJSON/documentation.json index f31382d3a..43224bc64 100644 --- a/test/libsolidity/ASTJSON/documentation.json +++ b/test/libsolidity/ASTJSON/documentation.json @@ -37,7 +37,8 @@ "nodes": [], "scope": 3, "src": "28:13:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "28:14:1" @@ -80,7 +81,8 @@ "nodes": [], "scope": 6, "src": "62:13:2", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "62:14:2" @@ -259,7 +261,11 @@ ], "scope": 24, "src": "0:213:3", - "usedErrors": [] + "usedErrors": [], + "usedEvents": + [ + 12 + ] } ], "src": "0:214:3" diff --git a/test/libsolidity/ASTJSON/documentation_local_variable.json b/test/libsolidity/ASTJSON/documentation_local_variable.json index 24e38eb1a..edaa89c18 100644 --- a/test/libsolidity/ASTJSON/documentation_local_variable.json +++ b/test/libsolidity/ASTJSON/documentation_local_variable.json @@ -484,7 +484,8 @@ ], "scope": 42, "src": "0:666:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:667:1" diff --git a/test/libsolidity/ASTJSON/documentation_local_variable_parseOnly.json b/test/libsolidity/ASTJSON/documentation_local_variable_parseOnly.json index 93fd1c9bd..872583839 100644 --- a/test/libsolidity/ASTJSON/documentation_local_variable_parseOnly.json +++ b/test/libsolidity/ASTJSON/documentation_local_variable_parseOnly.json @@ -350,7 +350,8 @@ } ], "src": "0:666:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:667:1" diff --git a/test/libsolidity/ASTJSON/documentation_on_statements.json b/test/libsolidity/ASTJSON/documentation_on_statements.json index bb3ee28d1..f7b424ea6 100644 --- a/test/libsolidity/ASTJSON/documentation_on_statements.json +++ b/test/libsolidity/ASTJSON/documentation_on_statements.json @@ -369,7 +369,8 @@ ], "scope": 28, "src": "0:330:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:331:1" diff --git a/test/libsolidity/ASTJSON/documentation_on_statements_parseOnly.json b/test/libsolidity/ASTJSON/documentation_on_statements_parseOnly.json index bb265a4cc..3872027cb 100644 --- a/test/libsolidity/ASTJSON/documentation_on_statements_parseOnly.json +++ b/test/libsolidity/ASTJSON/documentation_on_statements_parseOnly.json @@ -253,7 +253,8 @@ } ], "src": "0:330:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:331:1" diff --git a/test/libsolidity/ASTJSON/documentation_parseOnly.json b/test/libsolidity/ASTJSON/documentation_parseOnly.json index b3cda7e19..7f446279b 100644 --- a/test/libsolidity/ASTJSON/documentation_parseOnly.json +++ b/test/libsolidity/ASTJSON/documentation_parseOnly.json @@ -23,7 +23,8 @@ "nodeType": "ContractDefinition", "nodes": [], "src": "28:13:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "28:14:1" @@ -52,7 +53,8 @@ "nodeType": "ContractDefinition", "nodes": [], "src": "62:13:2", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "62:14:2" @@ -197,7 +199,8 @@ } ], "src": "0:213:3", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:214:3" diff --git a/test/libsolidity/ASTJSON/documentation_triple.json b/test/libsolidity/ASTJSON/documentation_triple.json index 9124e68b1..bd6f483b5 100644 --- a/test/libsolidity/ASTJSON/documentation_triple.json +++ b/test/libsolidity/ASTJSON/documentation_triple.json @@ -379,7 +379,8 @@ ], "scope": 29, "src": "0:267:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:268:1" diff --git a/test/libsolidity/ASTJSON/documentation_triple_parseOnly.json b/test/libsolidity/ASTJSON/documentation_triple_parseOnly.json index bd6612acc..5ccc2631c 100644 --- a/test/libsolidity/ASTJSON/documentation_triple_parseOnly.json +++ b/test/libsolidity/ASTJSON/documentation_triple_parseOnly.json @@ -256,7 +256,8 @@ } ], "src": "0:267:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:268:1" diff --git a/test/libsolidity/ASTJSON/enum_value.json b/test/libsolidity/ASTJSON/enum_value.json index 2cca00902..31615f657 100644 --- a/test/libsolidity/ASTJSON/enum_value.json +++ b/test/libsolidity/ASTJSON/enum_value.json @@ -56,7 +56,8 @@ ], "scope": 5, "src": "0:30:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:31:1" diff --git a/test/libsolidity/ASTJSON/enum_value_parseOnly.json b/test/libsolidity/ASTJSON/enum_value_parseOnly.json index 93b3cffcd..006e2db36 100644 --- a/test/libsolidity/ASTJSON/enum_value_parseOnly.json +++ b/test/libsolidity/ASTJSON/enum_value_parseOnly.json @@ -41,7 +41,8 @@ } ], "src": "0:30:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:31:1" diff --git a/test/libsolidity/ASTJSON/event_aggregated_contract.json b/test/libsolidity/ASTJSON/event_aggregated_contract.json new file mode 100644 index 000000000..e312320c1 --- /dev/null +++ b/test/libsolidity/ASTJSON/event_aggregated_contract.json @@ -0,0 +1,398 @@ +{ + "absolutePath": "a", + "exportedSymbols": + { + "C": + [ + 10 + ], + "D": + [ + 30 + ] + }, + "id": 31, + "nodeType": "SourceUnit", + "nodes": + [ + { + "abstract": false, + "baseContracts": [], + "canonicalName": "C", + "contractDependencies": [], + "contractKind": "contract", + "fullyImplemented": true, + "id": 10, + "linearizedBaseContracts": + [ + 10 + ], + "name": "C", + "nameLocation": "9:1:1", + "nodeType": "ContractDefinition", + "nodes": + [ + { + "anonymous": false, + "eventSelector": "ffae15ba29768297c9b951e2e14bc33dc84599d1572acc234266fc70392babc8", + "id": 2, + "name": "e", + "nameLocation": "23:1:1", + "nodeType": "EventDefinition", + "parameters": + { + "id": 1, + "nodeType": "ParameterList", + "parameters": [], + "src": "24:2:1" + }, + "src": "17:10:1" + }, + { + "body": + { + "id": 8, + "nodeType": "Block", + "src": "52:25:1", + "statements": + [ + { + "eventCall": + { + "arguments": [], + "expression": + { + "argumentTypes": [], + "id": 5, + "name": "e", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 2, + "src": "67:1:1", + "typeDescriptions": + { + "typeIdentifier": "t_function_event_nonpayable$__$returns$__$", + "typeString": "function ()" + } + }, + "id": 6, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "nameLocations": [], + "names": [], + "nodeType": "FunctionCall", + "src": "67:3:1", + "tryCall": false, + "typeDescriptions": + { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 7, + "nodeType": "EmitStatement", + "src": "62:8:1" + } + ] + }, + "functionSelector": "26121ff0", + "id": 9, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "f", + "nameLocation": "41:1:1", + "nodeType": "FunctionDefinition", + "parameters": + { + "id": 3, + "nodeType": "ParameterList", + "parameters": [], + "src": "42:2:1" + }, + "returnParameters": + { + "id": 4, + "nodeType": "ParameterList", + "parameters": [], + "src": "52:0:1" + }, + "scope": 10, + "src": "32:45:1", + "stateMutability": "nonpayable", + "virtual": false, + "visibility": "public" + } + ], + "scope": 31, + "src": "0:79:1", + "usedErrors": [], + "usedEvents": + [ + 2 + ] + }, + { + "abstract": false, + "baseContracts": [], + "canonicalName": "D", + "contractDependencies": + [ + 10 + ], + "contractKind": "contract", + "fullyImplemented": true, + "id": 30, + "linearizedBaseContracts": + [ + 30 + ], + "name": "D", + "nameLocation": "89:1:1", + "nodeType": "ContractDefinition", + "nodes": + [ + { + "constant": false, + "id": 13, + "mutability": "mutable", + "name": "c", + "nameLocation": "99:1:1", + "nodeType": "VariableDeclaration", + "scope": 30, + "src": "97:3:1", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": + { + "typeIdentifier": "t_contract$_C_$10", + "typeString": "contract C" + }, + "typeName": + { + "id": 12, + "nodeType": "UserDefinedTypeName", + "pathNode": + { + "id": 11, + "name": "C", + "nameLocations": + [ + "97:1:1" + ], + "nodeType": "IdentifierPath", + "referencedDeclaration": 10, + "src": "97:1:1" + }, + "referencedDeclaration": 10, + "src": "97:1:1", + "typeDescriptions": + { + "typeIdentifier": "t_contract$_C_$10", + "typeString": "contract C" + } + }, + "visibility": "internal" + }, + { + "body": + { + "id": 28, + "nodeType": "Block", + "src": "120:43:1", + "statements": + [ + { + "expression": + { + "id": 21, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": + { + "id": 16, + "name": "c", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 13, + "src": "130:1:1", + "typeDescriptions": + { + "typeIdentifier": "t_contract$_C_$10", + "typeString": "contract C" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": + { + "arguments": [], + "expression": + { + "argumentTypes": [], + "id": 19, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "nodeType": "NewExpression", + "src": "134:5:1", + "typeDescriptions": + { + "typeIdentifier": "t_function_creation_nonpayable$__$returns$_t_contract$_C_$10_$", + "typeString": "function () returns (contract C)" + }, + "typeName": + { + "id": 18, + "nodeType": "UserDefinedTypeName", + "pathNode": + { + "id": 17, + "name": "C", + "nameLocations": + [ + "138:1:1" + ], + "nodeType": "IdentifierPath", + "referencedDeclaration": 10, + "src": "138:1:1" + }, + "referencedDeclaration": 10, + "src": "138:1:1", + "typeDescriptions": + { + "typeIdentifier": "t_contract$_C_$10", + "typeString": "contract C" + } + } + }, + "id": 20, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "nameLocations": [], + "names": [], + "nodeType": "FunctionCall", + "src": "134:7:1", + "tryCall": false, + "typeDescriptions": + { + "typeIdentifier": "t_contract$_C_$10", + "typeString": "contract C" + } + }, + "src": "130:11:1", + "typeDescriptions": + { + "typeIdentifier": "t_contract$_C_$10", + "typeString": "contract C" + } + }, + "id": 22, + "nodeType": "ExpressionStatement", + "src": "130:11:1" + }, + { + "expression": + { + "arguments": [], + "expression": + { + "argumentTypes": [], + "expression": + { + "id": 23, + "name": "c", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 13, + "src": "151:1:1", + "typeDescriptions": + { + "typeIdentifier": "t_contract$_C_$10", + "typeString": "contract C" + } + }, + "id": 25, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberLocation": "153:1:1", + "memberName": "f", + "nodeType": "MemberAccess", + "referencedDeclaration": 9, + "src": "151:3:1", + "typeDescriptions": + { + "typeIdentifier": "t_function_external_nonpayable$__$returns$__$", + "typeString": "function () external" + } + }, + "id": 26, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "nameLocations": [], + "names": [], + "nodeType": "FunctionCall", + "src": "151:5:1", + "tryCall": false, + "typeDescriptions": + { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 27, + "nodeType": "ExpressionStatement", + "src": "151:5:1" + } + ] + }, + "id": 29, + "implemented": true, + "kind": "constructor", + "modifiers": [], + "name": "", + "nameLocation": "-1:-1:-1", + "nodeType": "FunctionDefinition", + "parameters": + { + "id": 14, + "nodeType": "ParameterList", + "parameters": [], + "src": "117:2:1" + }, + "returnParameters": + { + "id": 15, + "nodeType": "ParameterList", + "parameters": [], + "src": "120:0:1" + }, + "scope": 30, + "src": "106:57:1", + "stateMutability": "nonpayable", + "virtual": false, + "visibility": "public" + } + ], + "scope": 31, + "src": "80:85:1", + "usedErrors": [], + "usedEvents": [] + } + ], + "src": "0:166:1" +} diff --git a/test/libsolidity/ASTJSON/event_aggregated_contract.sol b/test/libsolidity/ASTJSON/event_aggregated_contract.sol new file mode 100644 index 000000000..b8fe2b276 --- /dev/null +++ b/test/libsolidity/ASTJSON/event_aggregated_contract.sol @@ -0,0 +1,15 @@ +contract C { + event e(); + function f() public { + emit e(); + } +} +contract D { + C c; + constructor() { + c = new C(); + c.f(); + } +} + +// ---- diff --git a/test/libsolidity/ASTJSON/event_definition.json b/test/libsolidity/ASTJSON/event_definition.json index 0bb614c22..b59164fcb 100644 --- a/test/libsolidity/ASTJSON/event_definition.json +++ b/test/libsolidity/ASTJSON/event_definition.json @@ -47,7 +47,11 @@ ], "scope": 4, "src": "0:25:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": + [ + 2 + ] } ], "src": "0:26:1" diff --git a/test/libsolidity/ASTJSON/event_definition_parseOnly.json b/test/libsolidity/ASTJSON/event_definition_parseOnly.json index ee5773a3b..9116b3d2d 100644 --- a/test/libsolidity/ASTJSON/event_definition_parseOnly.json +++ b/test/libsolidity/ASTJSON/event_definition_parseOnly.json @@ -32,7 +32,8 @@ } ], "src": "0:25:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:26:1" diff --git a/test/libsolidity/ASTJSON/event_emited_in_base_contract.json b/test/libsolidity/ASTJSON/event_emited_in_base_contract.json new file mode 100644 index 000000000..6b183b493 --- /dev/null +++ b/test/libsolidity/ASTJSON/event_emited_in_base_contract.json @@ -0,0 +1,289 @@ +{ + "absolutePath": "a", + "exportedSymbols": + { + "B": + [ + 16 + ], + "C": + [ + 19 + ], + "L": + [ + 5 + ] + }, + "id": 20, + "nodeType": "SourceUnit", + "nodes": + [ + { + "abstract": false, + "baseContracts": [], + "canonicalName": "L", + "contractDependencies": [], + "contractKind": "library", + "fullyImplemented": true, + "id": 5, + "linearizedBaseContracts": + [ + 5 + ], + "name": "L", + "nameLocation": "10:1:1", + "nodeType": "ContractDefinition", + "nodes": + [ + { + "anonymous": false, + "eventSelector": "870e3024466c178150e2490c7cfb455e33c0db877113af040f89189d07946664", + "id": 4, + "name": "E", + "nameLocation": "20:1:1", + "nodeType": "EventDefinition", + "parameters": + { + "id": 3, + "nodeType": "ParameterList", + "parameters": + [ + { + "constant": false, + "id": 2, + "indexed": false, + "mutability": "mutable", + "name": "", + "nameLocation": "-1:-1:-1", + "nodeType": "VariableDeclaration", + "scope": 4, + "src": "22:5:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": + { + "typeIdentifier": "t_uint8", + "typeString": "uint8" + }, + "typeName": + { + "id": 1, + "name": "uint8", + "nodeType": "ElementaryTypeName", + "src": "22:5:1", + "typeDescriptions": + { + "typeIdentifier": "t_uint8", + "typeString": "uint8" + } + }, + "visibility": "internal" + } + ], + "src": "21:7:1" + }, + "src": "14:15:1" + } + ], + "scope": 20, + "src": "0:31:1", + "usedErrors": [], + "usedEvents": + [ + 4 + ] + }, + { + "abstract": false, + "baseContracts": [], + "canonicalName": "B", + "contractDependencies": [], + "contractKind": "contract", + "fullyImplemented": true, + "id": 16, + "linearizedBaseContracts": + [ + 16 + ], + "name": "B", + "nameLocation": "41:1:1", + "nodeType": "ContractDefinition", + "nodes": + [ + { + "body": + { + "id": 14, + "nodeType": "Block", + "src": "63:28:1", + "statements": + [ + { + "eventCall": + { + "arguments": + [ + { + "hexValue": "30", + "id": 11, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "82:1:1", + "typeDescriptions": + { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + }, + "value": "0" + } + ], + "expression": + { + "argumentTypes": + [ + { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + } + ], + "expression": + { + "id": 8, + "name": "L", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 5, + "src": "78:1:1", + "typeDescriptions": + { + "typeIdentifier": "t_type$_t_contract$_L_$5_$", + "typeString": "type(library L)" + } + }, + "id": 10, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberLocation": "80:1:1", + "memberName": "E", + "nodeType": "MemberAccess", + "referencedDeclaration": 4, + "src": "78:3:1", + "typeDescriptions": + { + "typeIdentifier": "t_function_event_nonpayable$_t_uint8_$returns$__$", + "typeString": "function (uint8)" + } + }, + "id": 12, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "nameLocations": [], + "names": [], + "nodeType": "FunctionCall", + "src": "78:6:1", + "tryCall": false, + "typeDescriptions": + { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 13, + "nodeType": "EmitStatement", + "src": "73:11:1" + } + ] + }, + "id": 15, + "implemented": true, + "kind": "constructor", + "modifiers": [], + "name": "", + "nameLocation": "-1:-1:-1", + "nodeType": "FunctionDefinition", + "parameters": + { + "id": 6, + "nodeType": "ParameterList", + "parameters": [], + "src": "60:2:1" + }, + "returnParameters": + { + "id": 7, + "nodeType": "ParameterList", + "parameters": [], + "src": "63:0:1" + }, + "scope": 16, + "src": "49:42:1", + "stateMutability": "nonpayable", + "virtual": false, + "visibility": "public" + } + ], + "scope": 20, + "src": "32:61:1", + "usedErrors": [], + "usedEvents": + [ + 4 + ] + }, + { + "abstract": false, + "baseContracts": + [ + { + "baseName": + { + "id": 17, + "name": "B", + "nameLocations": + [ + "108:1:1" + ], + "nodeType": "IdentifierPath", + "referencedDeclaration": 16, + "src": "108:1:1" + }, + "id": 18, + "nodeType": "InheritanceSpecifier", + "src": "108:1:1" + } + ], + "canonicalName": "C", + "contractDependencies": [], + "contractKind": "contract", + "fullyImplemented": true, + "id": 19, + "linearizedBaseContracts": + [ + 19, + 16 + ], + "name": "C", + "nameLocation": "103:1:1", + "nodeType": "ContractDefinition", + "nodes": [], + "scope": 20, + "src": "94:18:1", + "usedErrors": [], + "usedEvents": + [ + 4 + ] + } + ], + "src": "0:113:1" +} diff --git a/test/libsolidity/ASTJSON/event_emited_in_base_contract.sol b/test/libsolidity/ASTJSON/event_emited_in_base_contract.sol new file mode 100644 index 000000000..303803233 --- /dev/null +++ b/test/libsolidity/ASTJSON/event_emited_in_base_contract.sol @@ -0,0 +1,9 @@ +library L { event E(uint8); } +contract B { + constructor() { + emit L.E(0); + } +} +contract C is B {} + +// ---- diff --git a/test/libsolidity/ASTJSON/event_inheritance.json b/test/libsolidity/ASTJSON/event_inheritance.json new file mode 100644 index 000000000..afa79e916 --- /dev/null +++ b/test/libsolidity/ASTJSON/event_inheritance.json @@ -0,0 +1,194 @@ +{ + "absolutePath": "a", + "exportedSymbols": + { + "B": + [ + 3 + ], + "C": + [ + 8 + ], + "D": + [ + 13 + ] + }, + "id": 14, + "nodeType": "SourceUnit", + "nodes": + [ + { + "abstract": false, + "baseContracts": [], + "canonicalName": "B", + "contractDependencies": [], + "contractKind": "interface", + "fullyImplemented": true, + "id": 3, + "linearizedBaseContracts": + [ + 3 + ], + "name": "B", + "nameLocation": "10:1:1", + "nodeType": "ContractDefinition", + "nodes": + [ + { + "anonymous": false, + "eventSelector": "dbec0351ad6bb0c1f07ea56e236e3e692fde2259f0165fd422f241da339b7e4f", + "id": 2, + "name": "EB", + "nameLocation": "24:2:1", + "nodeType": "EventDefinition", + "parameters": + { + "id": 1, + "nodeType": "ParameterList", + "parameters": [], + "src": "26:2:1" + }, + "src": "18:11:1" + } + ], + "scope": 14, + "src": "0:31:1", + "usedErrors": [], + "usedEvents": + [ + 2 + ] + }, + { + "abstract": false, + "baseContracts": + [ + { + "baseName": + { + "id": 4, + "name": "B", + "nameLocations": + [ + "46:1:1" + ], + "nodeType": "IdentifierPath", + "referencedDeclaration": 3, + "src": "46:1:1" + }, + "id": 5, + "nodeType": "InheritanceSpecifier", + "src": "46:1:1" + } + ], + "canonicalName": "C", + "contractDependencies": [], + "contractKind": "contract", + "fullyImplemented": true, + "id": 8, + "linearizedBaseContracts": + [ + 8, + 3 + ], + "name": "C", + "nameLocation": "41:1:1", + "nodeType": "ContractDefinition", + "nodes": + [ + { + "anonymous": false, + "eventSelector": "a08b3367d3fa83ea27f8951ffb5d9d160cbfadbd80816b47f677e7699d76f5a0", + "id": 7, + "name": "EC", + "nameLocation": "60:2:1", + "nodeType": "EventDefinition", + "parameters": + { + "id": 6, + "nodeType": "ParameterList", + "parameters": [], + "src": "62:2:1" + }, + "src": "54:11:1" + } + ], + "scope": 14, + "src": "32:35:1", + "usedErrors": [], + "usedEvents": + [ + 2, + 7 + ] + }, + { + "abstract": false, + "baseContracts": + [ + { + "baseName": + { + "id": 9, + "name": "C", + "nameLocations": + [ + "82:1:1" + ], + "nodeType": "IdentifierPath", + "referencedDeclaration": 8, + "src": "82:1:1" + }, + "id": 10, + "nodeType": "InheritanceSpecifier", + "src": "82:1:1" + } + ], + "canonicalName": "D", + "contractDependencies": [], + "contractKind": "contract", + "fullyImplemented": true, + "id": 13, + "linearizedBaseContracts": + [ + 13, + 8, + 3 + ], + "name": "D", + "nameLocation": "77:1:1", + "nodeType": "ContractDefinition", + "nodes": + [ + { + "anonymous": false, + "eventSelector": "caa54b91a2314ab89b39714b1cd283762e53a2f59cfb997d6770e2824c39db0d", + "id": 12, + "name": "ED", + "nameLocation": "96:2:1", + "nodeType": "EventDefinition", + "parameters": + { + "id": 11, + "nodeType": "ParameterList", + "parameters": [], + "src": "98:2:1" + }, + "src": "90:11:1" + } + ], + "scope": 14, + "src": "68:35:1", + "usedErrors": [], + "usedEvents": + [ + 2, + 7, + 12 + ] + } + ], + "src": "0:104:1" +} diff --git a/test/libsolidity/ASTJSON/event_inheritance.sol b/test/libsolidity/ASTJSON/event_inheritance.sol new file mode 100644 index 000000000..726873753 --- /dev/null +++ b/test/libsolidity/ASTJSON/event_inheritance.sol @@ -0,0 +1,11 @@ +interface B { + event EB(); +} +contract C is B { + event EC(); +} +contract D is C { + event ED(); +} + +// ---- diff --git a/test/libsolidity/ASTJSON/event_with_variables_of_internal_types_parseOnly.json b/test/libsolidity/ASTJSON/event_with_variables_of_internal_types_parseOnly.json index 0c90ee840..3ff426cb2 100644 --- a/test/libsolidity/ASTJSON/event_with_variables_of_internal_types_parseOnly.json +++ b/test/libsolidity/ASTJSON/event_with_variables_of_internal_types_parseOnly.json @@ -71,7 +71,8 @@ } ], "src": "0:48:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:49:1" diff --git a/test/libsolidity/ASTJSON/fail_after_parsing_parseOnly.json b/test/libsolidity/ASTJSON/fail_after_parsing_parseOnly.json index 5368d5862..f1d958617 100644 --- a/test/libsolidity/ASTJSON/fail_after_parsing_parseOnly.json +++ b/test/libsolidity/ASTJSON/fail_after_parsing_parseOnly.json @@ -289,7 +289,8 @@ } ], "src": "21:154:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:176:1" diff --git a/test/libsolidity/ASTJSON/fallback.json b/test/libsolidity/ASTJSON/fallback.json index 25a9b8588..f68c72ce6 100644 --- a/test/libsolidity/ASTJSON/fallback.json +++ b/test/libsolidity/ASTJSON/fallback.json @@ -66,7 +66,8 @@ ], "scope": 6, "src": "0:50:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:51:1" diff --git a/test/libsolidity/ASTJSON/fallback_and_reveice_ether.json b/test/libsolidity/ASTJSON/fallback_and_receive_ether.json similarity index 98% rename from test/libsolidity/ASTJSON/fallback_and_reveice_ether.json rename to test/libsolidity/ASTJSON/fallback_and_receive_ether.json index 26b4ada77..f41559d2a 100644 --- a/test/libsolidity/ASTJSON/fallback_and_reveice_ether.json +++ b/test/libsolidity/ASTJSON/fallback_and_receive_ether.json @@ -101,7 +101,8 @@ ], "scope": 10, "src": "0:85:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:86:1" diff --git a/test/libsolidity/ASTJSON/fallback_and_reveice_ether.sol b/test/libsolidity/ASTJSON/fallback_and_receive_ether.sol similarity index 100% rename from test/libsolidity/ASTJSON/fallback_and_reveice_ether.sol rename to test/libsolidity/ASTJSON/fallback_and_receive_ether.sol diff --git a/test/libsolidity/ASTJSON/fallback_and_reveice_ether_parseOnly.json b/test/libsolidity/ASTJSON/fallback_and_receive_ether_parseOnly.json similarity index 97% rename from test/libsolidity/ASTJSON/fallback_and_reveice_ether_parseOnly.json rename to test/libsolidity/ASTJSON/fallback_and_receive_ether_parseOnly.json index 55804a9f5..215bf3a83 100644 --- a/test/libsolidity/ASTJSON/fallback_and_reveice_ether_parseOnly.json +++ b/test/libsolidity/ASTJSON/fallback_and_receive_ether_parseOnly.json @@ -85,7 +85,8 @@ } ], "src": "0:85:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:86:1" diff --git a/test/libsolidity/ASTJSON/fallback_parseOnly.json b/test/libsolidity/ASTJSON/fallback_parseOnly.json index 4d626dcba..eb81fafbe 100644 --- a/test/libsolidity/ASTJSON/fallback_parseOnly.json +++ b/test/libsolidity/ASTJSON/fallback_parseOnly.json @@ -51,7 +51,8 @@ } ], "src": "0:50:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:51:1" diff --git a/test/libsolidity/ASTJSON/fallback_payable.json b/test/libsolidity/ASTJSON/fallback_payable.json index 4331b5edf..790351764 100644 --- a/test/libsolidity/ASTJSON/fallback_payable.json +++ b/test/libsolidity/ASTJSON/fallback_payable.json @@ -66,7 +66,8 @@ ], "scope": 6, "src": "0:38:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:39:1" diff --git a/test/libsolidity/ASTJSON/fallback_payable_parseOnly.json b/test/libsolidity/ASTJSON/fallback_payable_parseOnly.json index 2d029e56a..e1810828a 100644 --- a/test/libsolidity/ASTJSON/fallback_payable_parseOnly.json +++ b/test/libsolidity/ASTJSON/fallback_payable_parseOnly.json @@ -51,7 +51,8 @@ } ], "src": "0:38:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:39:1" diff --git a/test/libsolidity/ASTJSON/function_type.json b/test/libsolidity/ASTJSON/function_type.json index 924f9cdb9..e1a5156cf 100644 --- a/test/libsolidity/ASTJSON/function_type.json +++ b/test/libsolidity/ASTJSON/function_type.json @@ -225,7 +225,8 @@ ], "scope": 18, "src": "0:131:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:132:1" diff --git a/test/libsolidity/ASTJSON/function_type_parseOnly.json b/test/libsolidity/ASTJSON/function_type_parseOnly.json index fd1d7637b..64b09d5d9 100644 --- a/test/libsolidity/ASTJSON/function_type_parseOnly.json +++ b/test/libsolidity/ASTJSON/function_type_parseOnly.json @@ -173,7 +173,8 @@ } ], "src": "0:131:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:132:1" diff --git a/test/libsolidity/ASTJSON/indirect_event.json b/test/libsolidity/ASTJSON/indirect_event.json new file mode 100644 index 000000000..fcbe81756 --- /dev/null +++ b/test/libsolidity/ASTJSON/indirect_event.json @@ -0,0 +1,319 @@ +{ + "absolutePath": "a", + "exportedSymbols": + { + "C": + [ + 25 + ], + "L": + [ + 10 + ] + }, + "id": 26, + "license": "GPL-3.0", + "nodeType": "SourceUnit", + "nodes": + [ + { + "abstract": false, + "baseContracts": [], + "canonicalName": "L", + "contractDependencies": [], + "contractKind": "library", + "fullyImplemented": true, + "id": 10, + "linearizedBaseContracts": + [ + 10 + ], + "name": "L", + "nameLocation": "44:1:1", + "nodeType": "ContractDefinition", + "nodes": + [ + { + "anonymous": false, + "eventSelector": "92bbf6e823a631f3c8e09b1c8df90f378fb56f7fbc9701827e1ff8aad7f6a028", + "id": 2, + "name": "E", + "nameLocation": "58:1:1", + "nodeType": "EventDefinition", + "parameters": + { + "id": 1, + "nodeType": "ParameterList", + "parameters": [], + "src": "59:2:1" + }, + "src": "52:10:1" + }, + { + "body": + { + "id": 8, + "nodeType": "Block", + "src": "89:13:1", + "statements": + [ + { + "eventCall": + { + "arguments": [], + "expression": + { + "argumentTypes": [], + "id": 5, + "name": "E", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 2, + "src": "96:1:1", + "typeDescriptions": + { + "typeIdentifier": "t_function_event_nonpayable$__$returns$__$", + "typeString": "function ()" + } + }, + "id": 6, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "nameLocations": [], + "names": [], + "nodeType": "FunctionCall", + "src": "96:3:1", + "tryCall": false, + "typeDescriptions": + { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 7, + "nodeType": "EmitStatement", + "src": "91:8:1" + } + ] + }, + "id": 9, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "f", + "nameLocation": "76:1:1", + "nodeType": "FunctionDefinition", + "parameters": + { + "id": 3, + "nodeType": "ParameterList", + "parameters": [], + "src": "77:2:1" + }, + "returnParameters": + { + "id": 4, + "nodeType": "ParameterList", + "parameters": [], + "src": "89:0:1" + }, + "scope": 10, + "src": "67:35:1", + "stateMutability": "nonpayable", + "virtual": false, + "visibility": "internal" + } + ], + "scope": 26, + "src": "36:68:1", + "usedErrors": [], + "usedEvents": + [ + 2 + ] + }, + { + "abstract": false, + "baseContracts": [], + "canonicalName": "C", + "contractDependencies": [], + "contractKind": "contract", + "fullyImplemented": true, + "id": 25, + "linearizedBaseContracts": + [ + 25 + ], + "name": "C", + "nameLocation": "114:1:1", + "nodeType": "ContractDefinition", + "nodes": + [ + { + "anonymous": false, + "eventSelector": "70a5d861ef9816388422765f41d618eb3abdf490acb37354b539729e37b09f0e", + "id": 12, + "name": "H", + "nameLocation": "128:1:1", + "nodeType": "EventDefinition", + "parameters": + { + "id": 11, + "nodeType": "ParameterList", + "parameters": [], + "src": "129:2:1" + }, + "src": "122:10:1" + }, + { + "body": + { + "id": 23, + "nodeType": "Block", + "src": "157:20:1", + "statements": + [ + { + "expression": + { + "arguments": [], + "expression": + { + "argumentTypes": [], + "expression": + { + "id": 15, + "name": "L", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 10, + "src": "159:1:1", + "typeDescriptions": + { + "typeIdentifier": "t_type$_t_contract$_L_$10_$", + "typeString": "type(library L)" + } + }, + "id": 17, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberLocation": "161:1:1", + "memberName": "f", + "nodeType": "MemberAccess", + "referencedDeclaration": 9, + "src": "159:3:1", + "typeDescriptions": + { + "typeIdentifier": "t_function_internal_nonpayable$__$returns$__$", + "typeString": "function ()" + } + }, + "id": 18, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "nameLocations": [], + "names": [], + "nodeType": "FunctionCall", + "src": "159:5:1", + "tryCall": false, + "typeDescriptions": + { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 19, + "nodeType": "ExpressionStatement", + "src": "159:5:1" + }, + { + "eventCall": + { + "arguments": [], + "expression": + { + "argumentTypes": [], + "id": 20, + "name": "H", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 12, + "src": "171:1:1", + "typeDescriptions": + { + "typeIdentifier": "t_function_event_nonpayable$__$returns$__$", + "typeString": "function ()" + } + }, + "id": 21, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "nameLocations": [], + "names": [], + "nodeType": "FunctionCall", + "src": "171:3:1", + "tryCall": false, + "typeDescriptions": + { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 22, + "nodeType": "EmitStatement", + "src": "166:8:1" + } + ] + }, + "functionSelector": "e2179b8e", + "id": 24, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "g", + "nameLocation": "146:1:1", + "nodeType": "FunctionDefinition", + "parameters": + { + "id": 13, + "nodeType": "ParameterList", + "parameters": [], + "src": "147:2:1" + }, + "returnParameters": + { + "id": 14, + "nodeType": "ParameterList", + "parameters": [], + "src": "157:0:1" + }, + "scope": 25, + "src": "137:40:1", + "stateMutability": "nonpayable", + "virtual": false, + "visibility": "public" + } + ], + "scope": 26, + "src": "105:74:1", + "usedErrors": [], + "usedEvents": + [ + 2, + 12 + ] + } + ], + "src": "36:144:1" +} diff --git a/test/libsolidity/ASTJSON/indirect_event.sol b/test/libsolidity/ASTJSON/indirect_event.sol new file mode 100644 index 000000000..c4bba01c2 --- /dev/null +++ b/test/libsolidity/ASTJSON/indirect_event.sol @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: GPL-3.0 +library L { + event E(); + function f() internal { emit E(); } +} +contract C { + event H(); + function g() public { L.f(); emit H(); } +} + +// ---- diff --git a/test/libsolidity/ASTJSON/indirect_event_parseOnly.json b/test/libsolidity/ASTJSON/indirect_event_parseOnly.json new file mode 100644 index 000000000..17ca036d3 --- /dev/null +++ b/test/libsolidity/ASTJSON/indirect_event_parseOnly.json @@ -0,0 +1,228 @@ +{ + "absolutePath": "a", + "id": 26, + "license": "GPL-3.0", + "nodeType": "SourceUnit", + "nodes": + [ + { + "abstract": false, + "baseContracts": [], + "contractDependencies": [], + "contractKind": "library", + "id": 10, + "name": "L", + "nameLocation": "44:1:1", + "nodeType": "ContractDefinition", + "nodes": + [ + { + "anonymous": false, + "id": 2, + "name": "E", + "nameLocation": "58:1:1", + "nodeType": "EventDefinition", + "parameters": + { + "id": 1, + "nodeType": "ParameterList", + "parameters": [], + "src": "59:2:1" + }, + "src": "52:10:1" + }, + { + "body": + { + "id": 8, + "nodeType": "Block", + "src": "89:13:1", + "statements": + [ + { + "eventCall": + { + "arguments": [], + "expression": + { + "id": 5, + "name": "E", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "src": "96:1:1", + "typeDescriptions": {} + }, + "id": 6, + "nameLocations": [], + "names": [], + "nodeType": "FunctionCall", + "src": "96:3:1", + "tryCall": false, + "typeDescriptions": {} + }, + "id": 7, + "nodeType": "EmitStatement", + "src": "91:8:1" + } + ] + }, + "id": 9, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "f", + "nameLocation": "76:1:1", + "nodeType": "FunctionDefinition", + "parameters": + { + "id": 3, + "nodeType": "ParameterList", + "parameters": [], + "src": "77:2:1" + }, + "returnParameters": + { + "id": 4, + "nodeType": "ParameterList", + "parameters": [], + "src": "89:0:1" + }, + "src": "67:35:1", + "stateMutability": "nonpayable", + "virtual": false, + "visibility": "internal" + } + ], + "src": "36:68:1", + "usedErrors": [], + "usedEvents": [] + }, + { + "abstract": false, + "baseContracts": [], + "contractDependencies": [], + "contractKind": "contract", + "id": 25, + "name": "C", + "nameLocation": "114:1:1", + "nodeType": "ContractDefinition", + "nodes": + [ + { + "anonymous": false, + "id": 12, + "name": "H", + "nameLocation": "128:1:1", + "nodeType": "EventDefinition", + "parameters": + { + "id": 11, + "nodeType": "ParameterList", + "parameters": [], + "src": "129:2:1" + }, + "src": "122:10:1" + }, + { + "body": + { + "id": 23, + "nodeType": "Block", + "src": "157:20:1", + "statements": + [ + { + "expression": + { + "arguments": [], + "expression": + { + "expression": + { + "id": 15, + "name": "L", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "src": "159:1:1", + "typeDescriptions": {} + }, + "id": 17, + "memberLocation": "161:1:1", + "memberName": "f", + "nodeType": "MemberAccess", + "src": "159:3:1", + "typeDescriptions": {} + }, + "id": 18, + "nameLocations": [], + "names": [], + "nodeType": "FunctionCall", + "src": "159:5:1", + "tryCall": false, + "typeDescriptions": {} + }, + "id": 19, + "nodeType": "ExpressionStatement", + "src": "159:5:1" + }, + { + "eventCall": + { + "arguments": [], + "expression": + { + "id": 20, + "name": "H", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "src": "171:1:1", + "typeDescriptions": {} + }, + "id": 21, + "nameLocations": [], + "names": [], + "nodeType": "FunctionCall", + "src": "171:3:1", + "tryCall": false, + "typeDescriptions": {} + }, + "id": 22, + "nodeType": "EmitStatement", + "src": "166:8:1" + } + ] + }, + "id": 24, + "implemented": true, + "kind": "function", + "modifiers": [], + "name": "g", + "nameLocation": "146:1:1", + "nodeType": "FunctionDefinition", + "parameters": + { + "id": 13, + "nodeType": "ParameterList", + "parameters": [], + "src": "147:2:1" + }, + "returnParameters": + { + "id": 14, + "nodeType": "ParameterList", + "parameters": [], + "src": "157:0:1" + }, + "src": "137:40:1", + "stateMutability": "nonpayable", + "virtual": false, + "visibility": "public" + } + ], + "src": "105:74:1", + "usedErrors": [], + "usedEvents": [] + } + ], + "src": "36:144:1" +} diff --git a/test/libsolidity/ASTJSON/inheritance_specifier.json b/test/libsolidity/ASTJSON/inheritance_specifier.json index 8959d5b5d..ae210c949 100644 --- a/test/libsolidity/ASTJSON/inheritance_specifier.json +++ b/test/libsolidity/ASTJSON/inheritance_specifier.json @@ -33,7 +33,8 @@ "nodes": [], "scope": 5, "src": "0:14:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] }, { "abstract": false, @@ -73,7 +74,8 @@ "nodes": [], "scope": 5, "src": "15:20:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:36:1" diff --git a/test/libsolidity/ASTJSON/inheritance_specifier_parseOnly.json b/test/libsolidity/ASTJSON/inheritance_specifier_parseOnly.json index 72da9ad2c..171391b36 100644 --- a/test/libsolidity/ASTJSON/inheritance_specifier_parseOnly.json +++ b/test/libsolidity/ASTJSON/inheritance_specifier_parseOnly.json @@ -15,7 +15,8 @@ "nodeType": "ContractDefinition", "nodes": [], "src": "0:14:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] }, { "abstract": false, @@ -46,7 +47,8 @@ "nodeType": "ContractDefinition", "nodes": [], "src": "15:20:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:36:1" diff --git a/test/libsolidity/ASTJSON/license.json b/test/libsolidity/ASTJSON/license.json index 9f996e051..4c0882637 100644 --- a/test/libsolidity/ASTJSON/license.json +++ b/test/libsolidity/ASTJSON/license.json @@ -30,7 +30,8 @@ "nodes": [], "scope": 2, "src": "36:13:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "36:14:1" diff --git a/test/libsolidity/ASTJSON/license_parseOnly.json b/test/libsolidity/ASTJSON/license_parseOnly.json index 748b2548a..f2958f15f 100644 --- a/test/libsolidity/ASTJSON/license_parseOnly.json +++ b/test/libsolidity/ASTJSON/license_parseOnly.json @@ -16,7 +16,8 @@ "nodeType": "ContractDefinition", "nodes": [], "src": "36:13:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "36:14:1" diff --git a/test/libsolidity/ASTJSON/long_type_name_binary_operation.json b/test/libsolidity/ASTJSON/long_type_name_binary_operation.json index 8340eaf40..9bcd5e8fd 100644 --- a/test/libsolidity/ASTJSON/long_type_name_binary_operation.json +++ b/test/libsolidity/ASTJSON/long_type_name_binary_operation.json @@ -168,7 +168,8 @@ ], "scope": 12, "src": "0:54:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:55:1" diff --git a/test/libsolidity/ASTJSON/long_type_name_binary_operation_parseOnly.json b/test/libsolidity/ASTJSON/long_type_name_binary_operation_parseOnly.json index df2db3926..2cb372dd2 100644 --- a/test/libsolidity/ASTJSON/long_type_name_binary_operation_parseOnly.json +++ b/test/libsolidity/ASTJSON/long_type_name_binary_operation_parseOnly.json @@ -115,7 +115,8 @@ } ], "src": "0:54:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:55:1" diff --git a/test/libsolidity/ASTJSON/long_type_name_identifier.json b/test/libsolidity/ASTJSON/long_type_name_identifier.json index c810283d2..c22aeb40c 100644 --- a/test/libsolidity/ASTJSON/long_type_name_identifier.json +++ b/test/libsolidity/ASTJSON/long_type_name_identifier.json @@ -177,7 +177,8 @@ ], "scope": 16, "src": "0:70:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:71:1" diff --git a/test/libsolidity/ASTJSON/long_type_name_identifier_parseOnly.json b/test/libsolidity/ASTJSON/long_type_name_identifier_parseOnly.json index ef76f30aa..1bf50bed6 100644 --- a/test/libsolidity/ASTJSON/long_type_name_identifier_parseOnly.json +++ b/test/libsolidity/ASTJSON/long_type_name_identifier_parseOnly.json @@ -130,7 +130,8 @@ } ], "src": "0:70:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:71:1" diff --git a/test/libsolidity/ASTJSON/mappings.json b/test/libsolidity/ASTJSON/mappings.json index 0bf816eb4..81bf19db1 100644 --- a/test/libsolidity/ASTJSON/mappings.json +++ b/test/libsolidity/ASTJSON/mappings.json @@ -315,7 +315,8 @@ ], "scope": 24, "src": "0:173:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:174:1" diff --git a/test/libsolidity/ASTJSON/mappings_parseOnly.json b/test/libsolidity/ASTJSON/mappings_parseOnly.json index 9690f7c9e..84cfb4004 100644 --- a/test/libsolidity/ASTJSON/mappings_parseOnly.json +++ b/test/libsolidity/ASTJSON/mappings_parseOnly.json @@ -228,7 +228,8 @@ } ], "src": "0:173:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:174:1" diff --git a/test/libsolidity/ASTJSON/modifier_definition.json b/test/libsolidity/ASTJSON/modifier_definition.json index aa448568c..30ebcb7c2 100644 --- a/test/libsolidity/ASTJSON/modifier_definition.json +++ b/test/libsolidity/ASTJSON/modifier_definition.json @@ -169,7 +169,8 @@ ], "scope": 15, "src": "0:68:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:69:1" diff --git a/test/libsolidity/ASTJSON/modifier_definition_parseOnly.json b/test/libsolidity/ASTJSON/modifier_definition_parseOnly.json index 9344e419a..f8067952a 100644 --- a/test/libsolidity/ASTJSON/modifier_definition_parseOnly.json +++ b/test/libsolidity/ASTJSON/modifier_definition_parseOnly.json @@ -134,7 +134,8 @@ } ], "src": "0:68:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:69:1" diff --git a/test/libsolidity/ASTJSON/modifier_invocation.json b/test/libsolidity/ASTJSON/modifier_invocation.json index aa448568c..30ebcb7c2 100644 --- a/test/libsolidity/ASTJSON/modifier_invocation.json +++ b/test/libsolidity/ASTJSON/modifier_invocation.json @@ -169,7 +169,8 @@ ], "scope": 15, "src": "0:68:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:69:1" diff --git a/test/libsolidity/ASTJSON/modifier_invocation_parseOnly.json b/test/libsolidity/ASTJSON/modifier_invocation_parseOnly.json index 9344e419a..f8067952a 100644 --- a/test/libsolidity/ASTJSON/modifier_invocation_parseOnly.json +++ b/test/libsolidity/ASTJSON/modifier_invocation_parseOnly.json @@ -134,7 +134,8 @@ } ], "src": "0:68:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:69:1" diff --git a/test/libsolidity/ASTJSON/mutability.json b/test/libsolidity/ASTJSON/mutability.json index 90bbf05d5..b6318d84e 100644 --- a/test/libsolidity/ASTJSON/mutability.json +++ b/test/libsolidity/ASTJSON/mutability.json @@ -178,7 +178,8 @@ ], "scope": 11, "src": "0:102:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:103:1" diff --git a/test/libsolidity/ASTJSON/mutability_parseOnly.json b/test/libsolidity/ASTJSON/mutability_parseOnly.json index 88d3968f2..637f8e114 100644 --- a/test/libsolidity/ASTJSON/mutability_parseOnly.json +++ b/test/libsolidity/ASTJSON/mutability_parseOnly.json @@ -110,7 +110,8 @@ } ], "src": "0:102:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:103:1" diff --git a/test/libsolidity/ASTJSON/non_utf8.json b/test/libsolidity/ASTJSON/non_utf8.json index 926f858b5..0058e56eb 100644 --- a/test/libsolidity/ASTJSON/non_utf8.json +++ b/test/libsolidity/ASTJSON/non_utf8.json @@ -230,7 +230,8 @@ ], "scope": 16, "src": "0:80:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:81:1" diff --git a/test/libsolidity/ASTJSON/non_utf8_parseOnly.json b/test/libsolidity/ASTJSON/non_utf8_parseOnly.json index ef265cbe4..bbc350f96 100644 --- a/test/libsolidity/ASTJSON/non_utf8_parseOnly.json +++ b/test/libsolidity/ASTJSON/non_utf8_parseOnly.json @@ -149,7 +149,8 @@ } ], "src": "0:80:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:81:1" diff --git a/test/libsolidity/ASTJSON/not_existing_import_parseOnly.json b/test/libsolidity/ASTJSON/not_existing_import_parseOnly.json index de14043f3..ea08150fd 100644 --- a/test/libsolidity/ASTJSON/not_existing_import_parseOnly.json +++ b/test/libsolidity/ASTJSON/not_existing_import_parseOnly.json @@ -111,7 +111,8 @@ } ], "src": "41:90:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:132:1" diff --git a/test/libsolidity/ASTJSON/override.json b/test/libsolidity/ASTJSON/override.json index a7c43767f..35d36eac4 100644 --- a/test/libsolidity/ASTJSON/override.json +++ b/test/libsolidity/ASTJSON/override.json @@ -75,7 +75,8 @@ ], "scope": 30, "src": "0:48:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] }, { "abstract": true, @@ -193,7 +194,8 @@ ], "scope": 30, "src": "49:103:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] }, { "abstract": false, @@ -330,7 +332,8 @@ ], "scope": 30, "src": "153:91:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:245:1" diff --git a/test/libsolidity/ASTJSON/override_parseOnly.json b/test/libsolidity/ASTJSON/override_parseOnly.json index fe9d8a7c6..3a927f5f2 100644 --- a/test/libsolidity/ASTJSON/override_parseOnly.json +++ b/test/libsolidity/ASTJSON/override_parseOnly.json @@ -51,7 +51,8 @@ } ], "src": "0:48:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] }, { "abstract": true, @@ -152,7 +153,8 @@ } ], "src": "49:103:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] }, { "abstract": false, @@ -267,7 +269,8 @@ } ], "src": "153:91:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:245:1" diff --git a/test/libsolidity/ASTJSON/placeholder_statement.json b/test/libsolidity/ASTJSON/placeholder_statement.json index 5a6d51b21..96a46c148 100644 --- a/test/libsolidity/ASTJSON/placeholder_statement.json +++ b/test/libsolidity/ASTJSON/placeholder_statement.json @@ -61,7 +61,8 @@ ], "scope": 6, "src": "0:32:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:33:1" diff --git a/test/libsolidity/ASTJSON/placeholder_statement_parseOnly.json b/test/libsolidity/ASTJSON/placeholder_statement_parseOnly.json index 8f73cde60..8af170402 100644 --- a/test/libsolidity/ASTJSON/placeholder_statement_parseOnly.json +++ b/test/libsolidity/ASTJSON/placeholder_statement_parseOnly.json @@ -47,7 +47,8 @@ } ], "src": "0:32:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:33:1" diff --git a/test/libsolidity/ASTJSON/receive_ether.json b/test/libsolidity/ASTJSON/receive_ether.json index bfcb33f6c..279049399 100644 --- a/test/libsolidity/ASTJSON/receive_ether.json +++ b/test/libsolidity/ASTJSON/receive_ether.json @@ -66,7 +66,8 @@ ], "scope": 6, "src": "0:49:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:50:1" diff --git a/test/libsolidity/ASTJSON/receive_ether_parseOnly.json b/test/libsolidity/ASTJSON/receive_ether_parseOnly.json index 413c10564..f9aede155 100644 --- a/test/libsolidity/ASTJSON/receive_ether_parseOnly.json +++ b/test/libsolidity/ASTJSON/receive_ether_parseOnly.json @@ -51,7 +51,8 @@ } ], "src": "0:49:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:50:1" diff --git a/test/libsolidity/ASTJSON/short_type_name.json b/test/libsolidity/ASTJSON/short_type_name.json index b7409fbbc..1c1138cba 100644 --- a/test/libsolidity/ASTJSON/short_type_name.json +++ b/test/libsolidity/ASTJSON/short_type_name.json @@ -122,7 +122,8 @@ ], "scope": 12, "src": "0:55:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:56:1" diff --git a/test/libsolidity/ASTJSON/short_type_name_parseOnly.json b/test/libsolidity/ASTJSON/short_type_name_parseOnly.json index 02590363a..3c4acfa77 100644 --- a/test/libsolidity/ASTJSON/short_type_name_parseOnly.json +++ b/test/libsolidity/ASTJSON/short_type_name_parseOnly.json @@ -93,7 +93,8 @@ } ], "src": "0:55:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:56:1" diff --git a/test/libsolidity/ASTJSON/short_type_name_ref.json b/test/libsolidity/ASTJSON/short_type_name_ref.json index 6a0f249f8..447b1e5b7 100644 --- a/test/libsolidity/ASTJSON/short_type_name_ref.json +++ b/test/libsolidity/ASTJSON/short_type_name_ref.json @@ -133,7 +133,8 @@ ], "scope": 13, "src": "0:60:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:61:1" diff --git a/test/libsolidity/ASTJSON/short_type_name_ref_parseOnly.json b/test/libsolidity/ASTJSON/short_type_name_ref_parseOnly.json index 00799a212..07c782d47 100644 --- a/test/libsolidity/ASTJSON/short_type_name_ref_parseOnly.json +++ b/test/libsolidity/ASTJSON/short_type_name_ref_parseOnly.json @@ -100,7 +100,8 @@ } ], "src": "0:60:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:61:1" diff --git a/test/libsolidity/ASTJSON/smoke.json b/test/libsolidity/ASTJSON/smoke.json index 4d4a02e24..d3b114bbc 100644 --- a/test/libsolidity/ASTJSON/smoke.json +++ b/test/libsolidity/ASTJSON/smoke.json @@ -29,7 +29,8 @@ "nodes": [], "scope": 2, "src": "0:13:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:14:1" diff --git a/test/libsolidity/ASTJSON/smoke_parseOnly.json b/test/libsolidity/ASTJSON/smoke_parseOnly.json index d03e98654..1160fea91 100644 --- a/test/libsolidity/ASTJSON/smoke_parseOnly.json +++ b/test/libsolidity/ASTJSON/smoke_parseOnly.json @@ -15,7 +15,8 @@ "nodeType": "ContractDefinition", "nodes": [], "src": "0:13:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:14:1" diff --git a/test/libsolidity/ASTJSON/source_location.json b/test/libsolidity/ASTJSON/source_location.json index df51e49c6..caeaf027a 100644 --- a/test/libsolidity/ASTJSON/source_location.json +++ b/test/libsolidity/ASTJSON/source_location.json @@ -165,7 +165,8 @@ ], "scope": 13, "src": "0:55:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:56:1" diff --git a/test/libsolidity/ASTJSON/source_location_parseOnly.json b/test/libsolidity/ASTJSON/source_location_parseOnly.json index 88835788b..ec25111bd 100644 --- a/test/libsolidity/ASTJSON/source_location_parseOnly.json +++ b/test/libsolidity/ASTJSON/source_location_parseOnly.json @@ -119,7 +119,8 @@ } ], "src": "0:55:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:56:1" diff --git a/test/libsolidity/ASTJSON/string.json b/test/libsolidity/ASTJSON/string.json index 438f760c4..c7706e3bf 100644 --- a/test/libsolidity/ASTJSON/string.json +++ b/test/libsolidity/ASTJSON/string.json @@ -129,7 +129,8 @@ ], "scope": 10, "src": "0:71:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:72:1" diff --git a/test/libsolidity/ASTJSON/string_parseOnly.json b/test/libsolidity/ASTJSON/string_parseOnly.json index 444a1f7b2..5f97eb1f9 100644 --- a/test/libsolidity/ASTJSON/string_parseOnly.json +++ b/test/libsolidity/ASTJSON/string_parseOnly.json @@ -96,7 +96,8 @@ } ], "src": "0:71:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:72:1" diff --git a/test/libsolidity/ASTJSON/two_base_functions.json b/test/libsolidity/ASTJSON/two_base_functions.json index 23bdf6efe..0ed997a32 100644 --- a/test/libsolidity/ASTJSON/two_base_functions.json +++ b/test/libsolidity/ASTJSON/two_base_functions.json @@ -75,7 +75,8 @@ ], "scope": 23, "src": "0:49:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] }, { "abstract": false, @@ -133,7 +134,8 @@ ], "scope": 23, "src": "50:49:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] }, { "abstract": false, @@ -265,7 +267,8 @@ ], "scope": 23, "src": "100:64:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:165:1" diff --git a/test/libsolidity/ASTJSON/two_base_functions_parseOnly.json b/test/libsolidity/ASTJSON/two_base_functions_parseOnly.json index 078dc5daa..e448be836 100644 --- a/test/libsolidity/ASTJSON/two_base_functions_parseOnly.json +++ b/test/libsolidity/ASTJSON/two_base_functions_parseOnly.json @@ -51,7 +51,8 @@ } ], "src": "0:49:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] }, { "abstract": false, @@ -100,7 +101,8 @@ } ], "src": "50:49:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] }, { "abstract": false, @@ -212,7 +214,8 @@ } ], "src": "100:64:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:165:1" diff --git a/test/libsolidity/ASTJSON/unicode.json b/test/libsolidity/ASTJSON/unicode.json index dcb267b3f..0ff1426f1 100644 --- a/test/libsolidity/ASTJSON/unicode.json +++ b/test/libsolidity/ASTJSON/unicode.json @@ -129,7 +129,8 @@ ], "scope": 10, "src": "0:77:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:78:1" diff --git a/test/libsolidity/ASTJSON/unicode_parseOnly.json b/test/libsolidity/ASTJSON/unicode_parseOnly.json index a6f52aa4a..c8fb780c4 100644 --- a/test/libsolidity/ASTJSON/unicode_parseOnly.json +++ b/test/libsolidity/ASTJSON/unicode_parseOnly.json @@ -96,7 +96,8 @@ } ], "src": "0:77:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:78:1" diff --git a/test/libsolidity/ASTJSON/used_errors.json b/test/libsolidity/ASTJSON/used_errors.json index c59b4f530..12a59f9cb 100644 --- a/test/libsolidity/ASTJSON/used_errors.json +++ b/test/libsolidity/ASTJSON/used_errors.json @@ -228,7 +228,8 @@ [ 2, 11 - ] + ], + "usedEvents": [] } ], "src": "0:108:1" diff --git a/test/libsolidity/ASTJSON/used_errors_parseOnly.json b/test/libsolidity/ASTJSON/used_errors_parseOnly.json index 7a4b24b3c..115ea2aee 100644 --- a/test/libsolidity/ASTJSON/used_errors_parseOnly.json +++ b/test/libsolidity/ASTJSON/used_errors_parseOnly.json @@ -167,7 +167,8 @@ } ], "src": "45:62:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:108:1" diff --git a/test/libsolidity/ASTJSON/userDefinedValueType.json b/test/libsolidity/ASTJSON/userDefinedValueType.json index eb4450946..adf1172f0 100644 --- a/test/libsolidity/ASTJSON/userDefinedValueType.json +++ b/test/libsolidity/ASTJSON/userDefinedValueType.json @@ -352,7 +352,8 @@ ], "scope": 28, "src": "96:113:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:210:1" diff --git a/test/libsolidity/ASTJSON/userDefinedValueType_parseOnly.json b/test/libsolidity/ASTJSON/userDefinedValueType_parseOnly.json index 0dc95e13f..90e48a982 100644 --- a/test/libsolidity/ASTJSON/userDefinedValueType_parseOnly.json +++ b/test/libsolidity/ASTJSON/userDefinedValueType_parseOnly.json @@ -261,7 +261,8 @@ } ], "src": "96:113:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:210:1" diff --git a/test/libsolidity/ASTJSON/user_defined_operator.json b/test/libsolidity/ASTJSON/user_defined_operator.json index dd1c0d941..ed72de49d 100644 --- a/test/libsolidity/ASTJSON/user_defined_operator.json +++ b/test/libsolidity/ASTJSON/user_defined_operator.json @@ -656,7 +656,8 @@ ], "scope": 50, "src": "143:97:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:241:1" diff --git a/test/libsolidity/ASTJSON/using_for_directive.json b/test/libsolidity/ASTJSON/using_for_directive.json index 57658134d..f3094980f 100644 --- a/test/libsolidity/ASTJSON/using_for_directive.json +++ b/test/libsolidity/ASTJSON/using_for_directive.json @@ -72,7 +72,8 @@ "nodes": [], "scope": 14, "src": "20:12:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] }, { "body": @@ -179,7 +180,8 @@ ], "scope": 14, "src": "53:29:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:83:1" diff --git a/test/libsolidity/ASTJSON/using_for_directive_parseOnly.json b/test/libsolidity/ASTJSON/using_for_directive_parseOnly.json index 84de310c0..9360227d4 100644 --- a/test/libsolidity/ASTJSON/using_for_directive_parseOnly.json +++ b/test/libsolidity/ASTJSON/using_for_directive_parseOnly.json @@ -45,7 +45,8 @@ "nodeType": "ContractDefinition", "nodes": [], "src": "20:12:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] }, { "body": @@ -134,7 +135,8 @@ } ], "src": "53:29:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:83:1" diff --git a/test/libsolidity/ASTJSON/yul_hex_literal.json b/test/libsolidity/ASTJSON/yul_hex_literal.json index fc1cc39db..0b3fa4174 100644 --- a/test/libsolidity/ASTJSON/yul_hex_literal.json +++ b/test/libsolidity/ASTJSON/yul_hex_literal.json @@ -148,7 +148,8 @@ ], "scope": 7, "src": "0:216:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:217:1" diff --git a/test/libsolidity/ASTJSON/yul_hex_literal_parseOnly.json b/test/libsolidity/ASTJSON/yul_hex_literal_parseOnly.json index a6da7e778..3551ac2d9 100644 --- a/test/libsolidity/ASTJSON/yul_hex_literal_parseOnly.json +++ b/test/libsolidity/ASTJSON/yul_hex_literal_parseOnly.json @@ -132,7 +132,8 @@ } ], "src": "0:216:1", - "usedErrors": [] + "usedErrors": [], + "usedEvents": [] } ], "src": "0:217:1" diff --git a/test/libsolidity/SolidityNatspecJSON.cpp b/test/libsolidity/SolidityNatspecJSON.cpp index 3f83816c1..a54460eb6 100644 --- a/test/libsolidity/SolidityNatspecJSON.cpp +++ b/test/libsolidity/SolidityNatspecJSON.cpp @@ -485,6 +485,411 @@ BOOST_AUTO_TEST_CASE(event) checkNatspec(sourceCode, "ERC20", userDoc, true); } +BOOST_AUTO_TEST_CASE(emit_same_signature_event_library_contract) +{ + char const* sourceCode = R"( + library L { + /// @notice This event is defined in Library L + /// @dev This should not appear in Contract C dev doc + event SameSignatureEvent(uint16); + /// @notice This event is defined in Library L + /// @dev This should appear in Contract C dev doc + event LibraryEvent(uint32); + } + contract C { + /// @notice This event is defined in Contract C + /// @dev This should appear in Contract C dev doc + event SameSignatureEvent(uint16); + /// @notice This event is defined in Contract C + /// @dev This should appear in contract C dev doc + event ContractEvent(uint32); + function f() public { + emit L.SameSignatureEvent(0); + emit SameSignatureEvent(1); + emit L.LibraryEvent(2); + emit ContractEvent(3); + } + } + )"; + + char const* devDoc = R"ABCDEF( + { + "events": + { + "ContractEvent(uint32)": + { + "details": "This should appear in contract C dev doc" + }, + "LibraryEvent(uint32)": + { + "details": "This should appear in Contract C dev doc" + }, + "SameSignatureEvent(uint16)": + { + "details": "This should appear in Contract C dev doc" + } + }, + "kind": "dev", + "methods": {}, + "version": 1 + } + )ABCDEF"; + checkNatspec(sourceCode, "C", devDoc, false); + + char const* userDoc = R"ABCDEF( + { + "events": + { + "ContractEvent(uint32)": + { + "notice": "This event is defined in Contract C" + }, + "LibraryEvent(uint32)": + { + "notice": "This event is defined in Library L" + }, + "SameSignatureEvent(uint16)": + { + "notice": "This event is defined in Contract C" + } + }, + "kind": "user", + "methods": {}, + "version": 1 + } + )ABCDEF"; + checkNatspec(sourceCode, "C", userDoc, true); +} + +BOOST_AUTO_TEST_CASE(emit_same_signature_event_different_libraries) +{ + char const* sourceCode = R"( + library L1 { + /// @notice This event is defined in Library L1 + /// @dev This should not appear in Contract C dev doc + event SameSignatureEvent(uint16); + } + library L2 { + /// @notice This event is defined in Library L2 + /// @dev This should not appear in Contract C dev doc + event SameSignatureEvent(uint16); + } + library L3 { + /// @notice This event is defined in Library L3 + /// @dev This should not appear in Contract C dev doc + event SameSignatureEvent(uint16); + } + contract C { + function f() public { + emit L1.SameSignatureEvent(0); + emit L2.SameSignatureEvent(1); + emit L3.SameSignatureEvent(2); + } + } + )"; + + char const* devDoc = R"ABCDEF( + { + "kind": "dev", + "methods": {}, + "version": 1 + } + )ABCDEF"; + checkNatspec(sourceCode, "C", devDoc, false); + + char const* userDoc = R"ABCDEF( + { + "kind": "user", + "methods": {}, + "version": 1 + } + )ABCDEF"; + checkNatspec(sourceCode, "C", userDoc, true); + + char const* libraryDevDoc = R"ABCDEF( + { + "events": + { + "SameSignatureEvent(uint16)": + { + "details": "This should not appear in Contract C dev doc" + } + }, + "kind": "user", + "methods": {}, + "version": 1 + } + )ABCDEF"; + checkNatspec(sourceCode, "L1", libraryDevDoc, false); + + char const* libraryUserDoc = R"ABCDEF( + { + "events": + { + "SameSignatureEvent(uint16)": + { + "notice": "This event is defined in Library L1" + } + }, + "kind": "user", + "methods": {}, + "version": 1 + } + )ABCDEF"; + checkNatspec(sourceCode, "L1", libraryUserDoc, true); +} + +BOOST_AUTO_TEST_CASE(emit_same_signature_event_library_inherited) +{ + char const* sourceCode = R"( + contract D { + /// @notice This event is defined in contract D + /// @dev This should appear in Contract C dev doc + event SameSignatureEvent(uint16); + } + library L { + /// @notice This event is defined in Library L + /// @dev This should not appear in Contract C + event SameSignatureEvent(uint16); + } + contract C is D { + function f() public { + emit L.SameSignatureEvent(0); + emit D.SameSignatureEvent(1); + } + } + )"; + + char const* devDoc = R"ABCDEF( + { + "events": + { + "SameSignatureEvent(uint16)": + { + "details": "This should appear in Contract C dev doc" + } + }, + "kind": "dev", + "methods": {}, + "version": 1 + } + )ABCDEF"; + checkNatspec(sourceCode, "C", devDoc, false); + + char const* userDoc = R"ABCDEF( + { + "events": + { + "SameSignatureEvent(uint16)": + { + "notice": "This event is defined in contract D" + } + }, + "kind": "user", + "methods": {}, + "version": 1 + } + )ABCDEF"; + checkNatspec(sourceCode, "C", userDoc, true); +} + +BOOST_AUTO_TEST_CASE(emit_same_signature_event_library_contract_missing_natspec) +{ + char const* sourceCode = R"( + library L { + /// @notice This event is defined in library L + /// @dev This should not appear in contract C devdoc + event SameSignatureEvent(uint16); + /// @notice This event is defined in library L + /// @dev This should appear in contract C devdoc + event LibraryEvent(uint32); + } + contract C { + event SameSignatureEvent(uint16); + /// @notice This event is defined in contract C + event ContractEvent(uint32); + function f() public { + emit L.SameSignatureEvent(0); + emit SameSignatureEvent(1); + emit L.LibraryEvent(2); + emit ContractEvent(3); + } + } + )"; + + char const* devDoc = R"ABCDEF( + { + "events": + { + "LibraryEvent(uint32)": + { + "details": "This should appear in contract C devdoc" + } + }, + "kind": "dev", + "methods": {}, + "version": 1 + } + )ABCDEF"; + checkNatspec(sourceCode, "C", devDoc, false); + + char const* userDoc = R"ABCDEF( + { + "events": + { + "ContractEvent(uint32)": + { + "notice": "This event is defined in contract C" + }, + "LibraryEvent(uint32)": + { + "notice": "This event is defined in library L" + } + }, + "kind": "user", + "methods": {}, + "version": 1 + } + )ABCDEF"; + checkNatspec(sourceCode, "C", userDoc, true); +} + +BOOST_AUTO_TEST_CASE(emit_same_signature_event_different_libraries_missing_natspec) +{ + char const* sourceCode = R"( + library L1 { + event SameSignatureEvent(uint16); + } + library L2 { + /// @notice This event is defined in library L2 + /// @dev This should not appear in Contract C devdoc + event SameSignatureEvent(uint16); + } + library L3 { + event SameSignatureEvent(uint16); + } + contract C { + function f() public { + emit L1.SameSignatureEvent(0); + emit L2.SameSignatureEvent(1); + emit L3.SameSignatureEvent(2); + } + } + )"; + + char const* devDoc = R"ABCDEF( + { + "kind": "dev", + "methods": {}, + "version": 1 + } + )ABCDEF"; + checkNatspec(sourceCode, "C", devDoc, false); + + char const* userDoc = R"ABCDEF( + { + "kind": "user", + "methods": {}, + "version": 1 + } + )ABCDEF"; + checkNatspec(sourceCode, "C", userDoc, true); +} + +BOOST_AUTO_TEST_CASE(emit_same_signature_event_library_inherited_missing_natspec) +{ + char const* sourceCode = R"( + contract D { + event SameSignatureEvent(uint16); + } + library L { + /// @notice This event is defined in library L + /// @dev This should not appear in contract C devdoc + event SameSignatureEvent(uint16); + } + contract C is D { + function f() public { + emit L.SameSignatureEvent(0); + emit D.SameSignatureEvent(1); + } + } + )"; + + char const* devDoc = R"ABCDEF( + { + "kind": "dev", + "methods": {}, + "version": 1 + } + )ABCDEF"; + checkNatspec(sourceCode, "C", devDoc, false); + + char const* userDoc = R"ABCDEF( + { + "kind": "user", + "methods": {}, + "version": 1 + } + )ABCDEF"; + checkNatspec(sourceCode, "C", userDoc, true); +} + +BOOST_AUTO_TEST_CASE(event_inheritance_interface) +{ + char const* sourceCode = R"( + interface ERC20 { + /// @notice This event is emitted when a transfer occurs. + /// @param from The source account. + /// @param to The destination account. + /// @param amount The amount. + /// @dev A test case! + event Transfer(address indexed from, address indexed to, uint amount); + } + contract A is ERC20 { + } + contract B is A { + } + )"; + + char const* devDoc = R"ABCDEF( + { + "events": + { + "Transfer(address,address,uint256)": + { + "details": "A test case!", + "params": + { + "amount": "The amount.", + "from": "The source account.", + "to": "The destination account." + } + } + }, + "methods": {} + } + )ABCDEF"; + checkNatspec(sourceCode, "ERC20", devDoc, false); + checkNatspec(sourceCode, "A", devDoc, false); + checkNatspec(sourceCode, "B", devDoc, false); + + char const* userDoc = R"ABCDEF( + { + "events": + { + "Transfer(address,address,uint256)": + { + "notice": "This event is emitted when a transfer occurs." + } + }, + "methods": {} + } + )ABCDEF"; + checkNatspec(sourceCode, "ERC20", userDoc, true); + checkNatspec(sourceCode, "A", userDoc, true); + checkNatspec(sourceCode, "B", userDoc, true); +} + BOOST_AUTO_TEST_CASE(event_inheritance) { char const* sourceCode = R"( @@ -496,10 +901,8 @@ BOOST_AUTO_TEST_CASE(event_inheritance) /// @dev A test case! event Transfer(address indexed from, address indexed to, uint amount); } - contract A is ERC20 { } - contract B is A { } )"; diff --git a/test/libsolidity/StandardCompiler.cpp b/test/libsolidity/StandardCompiler.cpp index d2eeedd91..086cde8ef 100644 --- a/test/libsolidity/StandardCompiler.cpp +++ b/test/libsolidity/StandardCompiler.cpp @@ -485,9 +485,10 @@ BOOST_AUTO_TEST_CASE(basic_compilation) BOOST_CHECK_EQUAL( util::jsonCompactPrint(result["sources"]["fileA"]["ast"]), "{\"absolutePath\":\"fileA\",\"exportedSymbols\":{\"A\":[1]},\"id\":2,\"nodeType\":\"SourceUnit\",\"nodes\":[{\"abstract\":false," - "\"baseContracts\":[],\"canonicalName\":\"A\",\"contractDependencies\":[],\"contractKind\":\"contract\",\"fullyImplemented\":true,\"id\":1," + "\"baseContracts\":[],\"canonicalName\":\"A\",\"contractDependencies\":[]," + "\"contractKind\":\"contract\",\"fullyImplemented\":true,\"id\":1," "\"linearizedBaseContracts\":[1],\"name\":\"A\",\"nameLocation\":\"9:1:0\",\"nodeType\":\"ContractDefinition\",\"nodes\":[],\"scope\":2," - "\"src\":\"0:14:0\",\"usedErrors\":[]}],\"src\":\"0:14:0\"}" + "\"src\":\"0:14:0\",\"usedErrors\":[],\"usedEvents\":[]}],\"src\":\"0:14:0\"}" ); }