├── .github └── workflows │ ├── gendocs.yml │ └── python-ci.yml ├── .gitignore ├── CHANGELOG.MD ├── LICENSE ├── README.md ├── docrequirements.txt ├── docs ├── Makefile ├── imgs │ ├── astmods2.png │ ├── exampledir.png │ ├── gptdir.png │ ├── parseTree.png │ ├── sourceunits.png │ └── toplevelunits.png ├── make.bat └── source │ ├── conf.py │ ├── getstarted │ ├── builtins.sol │ ├── clients.rst │ ├── index.rst │ ├── prereq.rst │ ├── quickstart.rst │ ├── scopes.rst │ ├── sourcecode.rst │ ├── twoASTs.rst │ └── vfshooks.rst │ └── index.rst ├── example ├── gptcomment.py ├── gptcomments │ └── TheContract.sol ├── librarycall │ ├── AdderLib.sol │ └── TestContract.sol ├── project │ ├── contracts │ │ ├── FloatingFunc.sol │ │ └── TestContract.sol │ ├── lib │ │ └── oz │ │ │ └── access │ │ │ └── Ownable.sol │ └── remappings.txt └── quickstart.py ├── requirements.txt ├── setup.py ├── setup.sh ├── src └── solidity_parser │ ├── __init__.py │ ├── ast │ ├── __init__.py │ ├── ast2builder.py │ ├── funcanalysis.py │ ├── helper.py │ ├── hierarchy.py │ ├── mro_helper.py │ ├── nodebase.py │ ├── parsers │ │ ├── __init__.py │ │ ├── common.py │ │ ├── errors.py │ │ ├── parsers060.py │ │ ├── parsers070.py │ │ ├── parsers080.py │ │ ├── parsers088.py │ │ └── parsers08_22.py │ ├── solnodes.py │ ├── solnodes2.py │ ├── symtab.py │ └── types.py │ ├── collectors │ ├── __init__.py │ ├── collector.py │ ├── v000.py │ ├── v060.py │ ├── v070.py │ └── v080.py │ ├── errors.py │ ├── filesys.py │ ├── grammar │ ├── __init__.py │ ├── v060 │ │ ├── Solidity.g4 │ │ └── __init__.py │ ├── v070 │ │ ├── Solidity.g4 │ │ └── __init__.py │ ├── v080 │ │ ├── SolidityLexer.g4 │ │ ├── SolidityParser.g4 │ │ └── __init__.py │ ├── v088 │ │ ├── SolidityLexer.g4 │ │ ├── SolidityParser.g4 │ │ └── __init__.py │ └── v08_22 │ │ ├── SolidityLexer.g4 │ │ ├── SolidityParser.g4 │ │ └── __init__.py │ └── util │ ├── __init__.py │ └── version_util.py ├── test ├── __init__.py └── solidity_parser │ ├── __init__.py │ ├── ast │ ├── __init__.py │ ├── helper.py │ ├── snapshots │ │ ├── __init__.py │ │ ├── snap_test_ast2builder.py │ │ ├── snap_test_imports.py │ │ └── snap_test_parsing.py │ ├── test_ast2builder.py │ ├── test_imports.py │ ├── test_mro_helper.py │ ├── test_parsing.py │ ├── test_solnodes2.py │ ├── test_udvt.py │ └── test_using_directives.py │ └── test_filesys.py ├── testcases ├── 0.1.3 │ └── SelfUsing.sol ├── 08_22 │ ├── NegOperator.sol │ ├── NegOperatorNotEnoughArgs.sol │ ├── OperatorAttachAndBind.sol │ ├── OperatorAttachAndBindFailureCase.sol │ ├── OperatorAttachAndBindWithImport.sol │ ├── OperatorUsing.sol │ └── SourceUnits.sol ├── imports │ ├── ImportA.sol │ ├── ImportB.sol │ └── ImportedStateVar.sol ├── libsolidity │ ├── ASTJSON │ │ ├── abstract_contract.sol │ │ ├── address_payable.sol │ │ ├── array_type_name.sol │ │ ├── ast_internal_function_different_ids_export.sol │ │ ├── ast_internal_function_id_export.sol │ │ ├── base_constructor_call.sol │ │ ├── constructor.sol │ │ ├── contract_dep_order.sol │ │ ├── documentation.sol │ │ ├── documentation_local_variable.sol │ │ ├── documentation_on_statements.sol │ │ ├── documentation_triple.sol │ │ ├── enum_natspec.sol │ │ ├── enum_value.sol │ │ ├── enum_value_declaration.sol │ │ ├── event_aggregated_contract.sol │ │ ├── event_definition.sol │ │ ├── event_emited_in_base_contract.sol │ │ ├── event_emitted_from_foreign_contract.sol │ │ ├── event_inheritance.sol │ │ ├── event_with_variables_of_internal_types.sol │ │ ├── fail_after_parsing.sol │ │ ├── fallback.sol │ │ ├── fallback_and_receive_ether.sol │ │ ├── fallback_payable.sol │ │ ├── function_type.sol │ │ ├── global_enum.sol │ │ ├── global_struct.sol │ │ ├── indirect_event.sol │ │ ├── inheritance_specifier.sol │ │ ├── license.sol │ │ ├── long_type_name_binary_operation.sol │ │ ├── long_type_name_identifier.sol │ │ ├── mappings.sol │ │ ├── modifier_definition.sol │ │ ├── modifier_invocation.sol │ │ ├── mutability.sol │ │ ├── non_utf8.sol │ │ ├── not_existing_import.sol │ │ ├── override.sol │ │ ├── placeholder_statement.sol │ │ ├── pragma_experimental_solidity.sol │ │ ├── receive_ether.sol │ │ ├── short_type_name.sol │ │ ├── short_type_name_ref.sol │ │ ├── smoke.sol │ │ ├── source_location.sol │ │ ├── string.sol │ │ ├── struct_natspec.sol │ │ ├── two_base_functions.sol │ │ ├── unicode.sol │ │ ├── used_errors.sol │ │ ├── userDefinedValueType.sol │ │ ├── user_defined_operator.sol │ │ ├── using_for_directive.sol │ │ └── yul_hex_literal.sol │ └── semanticTests │ │ ├── abiEncoderV1 │ │ ├── abi_decode_dynamic_array.sol │ │ ├── abi_decode_fixed_arrays.sol │ │ ├── abi_decode_static_array.sol │ │ ├── abi_decode_static_array_v2.sol │ │ ├── abi_decode_trivial.sol │ │ ├── abi_decode_v2.sol │ │ ├── abi_decode_v2_calldata.sol │ │ ├── abi_decode_v2_storage.sol │ │ ├── abi_encode.sol │ │ ├── abi_encode_call.sol │ │ ├── abi_encode_calldata_slice.sol │ │ ├── abi_encode_decode_simple.sol │ │ ├── abi_encode_empty_string.sol │ │ ├── abi_encode_rational.sol │ │ ├── bool_out_of_bounds.sol │ │ ├── byte_arrays.sol │ │ ├── calldata_arrays_too_large.sol │ │ ├── calldata_bytes_bytes32_arrays.sol │ │ ├── cleanup │ │ │ └── cleanup.sol │ │ ├── decode_slice.sol │ │ ├── dynamic_arrays.sol │ │ ├── dynamic_memory_copy.sol │ │ ├── enums.sol │ │ ├── memory_dynamic_array_and_calldata_bytes.sol │ │ ├── memory_params_in_external_function.sol │ │ ├── return_dynamic_types_cross_call_advanced.sol │ │ ├── return_dynamic_types_cross_call_out_of_range_1.sol │ │ ├── return_dynamic_types_cross_call_out_of_range_2.sol │ │ ├── return_dynamic_types_cross_call_simple.sol │ │ └── struct │ │ │ └── struct_storage_ptr.sol │ │ ├── abiEncoderV2 │ │ ├── abi_encode_calldata_slice.sol │ │ ├── abi_encode_empty_string_v2.sol │ │ ├── abi_encode_rational_v2.sol │ │ ├── abi_encode_v2.sol │ │ ├── abi_encode_v2_in_function_inherited_in_v1_contract.sol │ │ ├── abi_encode_v2_in_modifier_used_in_v1_contract.sol │ │ ├── abi_encoder_v2_head_overflow_with_static_array_cleanup_bug.sol │ │ ├── bool_out_of_bounds.sol │ │ ├── byte_arrays.sol │ │ ├── calldata_array.sol │ │ ├── calldata_array_dynamic.sol │ │ ├── calldata_array_dynamic_index_access.sol │ │ ├── calldata_array_dynamic_static_dynamic.sol │ │ ├── calldata_array_dynamic_static_in_library.sol │ │ ├── calldata_array_dynamic_static_short_decode.sol │ │ ├── calldata_array_dynamic_static_short_reencode.sol │ │ ├── calldata_array_function_types.sol │ │ ├── calldata_array_multi_dynamic.sol │ │ ├── calldata_array_short.sol │ │ ├── calldata_array_short_no_revert_string.sol │ │ ├── calldata_array_static.sol │ │ ├── calldata_array_static_dynamic_static.sol │ │ ├── calldata_array_static_index_access.sol │ │ ├── calldata_array_struct_dynamic.sol │ │ ├── calldata_array_two_dynamic.sol │ │ ├── calldata_array_two_static.sol │ │ ├── calldata_dynamic_array_to_memory.sol │ │ ├── calldata_nested_array_reencode.sol │ │ ├── calldata_nested_array_static_reencode.sol │ │ ├── calldata_overlapped_dynamic_arrays.sol │ │ ├── calldata_overlapped_nested_dynamic_arrays.sol │ │ ├── calldata_struct_array_reencode.sol │ │ ├── calldata_struct_dynamic.sol │ │ ├── calldata_struct_member_offset.sol │ │ ├── calldata_struct_simple.sol │ │ ├── calldata_three_dimensional_dynamic_array_index_access.sol │ │ ├── calldata_with_garbage.sol │ │ ├── cleanup │ │ │ ├── address.sol │ │ │ ├── bool.sol │ │ │ ├── bytesx.sol │ │ │ ├── cleanup.sol │ │ │ ├── dynamic_array.sol │ │ │ ├── function.sol │ │ │ ├── intx.sol │ │ │ ├── reencoded_calldata_string.sol │ │ │ ├── simple_struct.sol │ │ │ ├── static_array.sol │ │ │ └── uintx.sol │ │ ├── dynamic_arrays.sol │ │ ├── dynamic_nested_arrays.sol │ │ ├── enums.sol │ │ ├── memory_dynamic_array_and_calldata_bytes.sol │ │ ├── memory_dynamic_array_and_calldata_static_array.sol │ │ ├── memory_params_in_external_function.sol │ │ ├── storage_array_encoding.sol │ │ └── struct │ │ │ ├── mediocre2_struct.sol │ │ │ ├── mediocre_struct.sol │ │ │ ├── struct_function.sol │ │ │ ├── struct_short.sol │ │ │ ├── struct_simple.sol │ │ │ ├── struct_validation.sol │ │ │ └── validation_function_type_inside_struct.sol │ │ ├── abiencodedecode │ │ ├── abi_decode_calldata.sol │ │ ├── abi_decode_simple.sol │ │ ├── abi_decode_simple_storage.sol │ │ ├── abi_encode_call.sol │ │ ├── abi_encode_call_declaration.sol │ │ ├── abi_encode_call_is_consistent.sol │ │ ├── abi_encode_call_memory.sol │ │ ├── abi_encode_call_special_args.sol │ │ ├── abi_encode_call_uint_bytes.sol │ │ ├── abi_encode_empty_string_v1.sol │ │ ├── abi_encode_with_selector.sol │ │ ├── abi_encode_with_selectorv2.sol │ │ ├── abi_encode_with_signature.sol │ │ ├── abi_encode_with_signaturev2.sol │ │ ├── contract_array.sol │ │ ├── contract_array_v2.sol │ │ ├── offset_overflow_in_array_decoding.sol │ │ ├── offset_overflow_in_array_decoding_2.sol │ │ └── offset_overflow_in_array_decoding_3.sol │ │ ├── accessor │ │ ├── accessor_for_const_state_variable.sol │ │ └── accessor_for_state_variable.sol │ │ ├── arithmetics │ │ ├── addmod_mulmod.sol │ │ ├── addmod_mulmod_zero.sol │ │ ├── block_inside_unchecked.sol │ │ ├── check_var_init.sol │ │ ├── checked_add_v1.sol │ │ ├── checked_add_v2.sol │ │ ├── checked_called_by_unchecked.sol │ │ ├── checked_modifier_called_by_unchecked.sol │ │ ├── divisiod_by_zero.sol │ │ ├── exp_associativity.sol │ │ ├── signed_mod.sol │ │ ├── unchecked_called_by_checked.sol │ │ └── unchecked_div_by_zero.sol │ │ ├── array │ │ ├── array_2d_assignment.sol │ │ ├── array_2d_new.sol │ │ ├── array_3d_assignment.sol │ │ ├── array_3d_new.sol │ │ ├── array_function_pointers.sol │ │ ├── array_memory_allocation │ │ │ ├── array_2d_zeroed_memory_index_access.sol │ │ │ ├── array_array_static.sol │ │ │ ├── array_static_return_param_zeroed_memory_index_access.sol │ │ │ ├── array_static_zeroed_memory_index_access.sol │ │ │ └── array_zeroed_memory_index_access.sol │ │ ├── array_memory_as_parameter.sol │ │ ├── array_memory_create.sol │ │ ├── array_memory_index_access.sol │ │ ├── array_push_return_reference.sol │ │ ├── array_push_with_arg.sol │ │ ├── array_storage_index_access.sol │ │ ├── array_storage_index_boundary_test.sol │ │ ├── array_storage_index_zeroed_test.sol │ │ ├── array_storage_length_access.sol │ │ ├── array_storage_pop_zero_length.sol │ │ ├── array_storage_push_empty.sol │ │ ├── array_storage_push_empty_length_address.sol │ │ ├── array_storage_push_pop.sol │ │ ├── arrays_complex_from_and_to_storage.sol │ │ ├── byte_array_storage_layout.sol │ │ ├── byte_array_transitional_2.sol │ │ ├── bytes_length_member.sol │ │ ├── bytes_to_fixed_bytes_cleanup.sol │ │ ├── bytes_to_fixed_bytes_simple.sol │ │ ├── bytes_to_fixed_bytes_too_long.sol │ │ ├── calldata_array.sol │ │ ├── calldata_array_as_argument_internal_function.sol │ │ ├── calldata_array_dynamic_invalid.sol │ │ ├── calldata_array_dynamic_invalid_static_middle.sol │ │ ├── calldata_array_of_struct.sol │ │ ├── calldata_array_two_dimensional.sol │ │ ├── calldata_array_two_dimensional_1.sol │ │ ├── calldata_bytes_array_bounds.sol │ │ ├── calldata_slice_access.sol │ │ ├── concat │ │ │ ├── bytes_concat_2_args.sol │ │ │ ├── bytes_concat_3_args.sol │ │ │ ├── bytes_concat_as_argument.sol │ │ │ ├── bytes_concat_different_types.sol │ │ │ ├── bytes_concat_empty_argument_list.sol │ │ │ ├── bytes_concat_empty_strings.sol │ │ │ └── bytes_concat_nested.sol │ │ ├── constant_var_as_array_length.sol │ │ ├── copying │ │ │ ├── array_copy_calldata_storage.sol │ │ │ ├── array_copy_cleanup_uint128.sol │ │ │ ├── array_copy_cleanup_uint40.sol │ │ │ ├── array_copy_clear_storage.sol │ │ │ ├── array_copy_clear_storage_packed.sol │ │ │ ├── array_copy_different_packing.sol │ │ │ ├── array_copy_including_array.sol │ │ │ ├── array_copy_memory_to_storage.sol │ │ │ ├── array_copy_nested_array.sol │ │ │ ├── array_copy_storage_abi_signed.sol │ │ │ ├── array_copy_storage_storage_different_base.sol │ │ │ ├── array_copy_storage_storage_different_base_nested.sol │ │ │ ├── array_copy_storage_storage_dyn_dyn.sol │ │ │ ├── array_copy_storage_storage_dynamic_dynamic.sol │ │ │ ├── array_copy_storage_storage_static_dynamic.sol │ │ │ ├── array_copy_storage_storage_static_simple.sol │ │ │ ├── array_copy_storage_storage_static_static.sol │ │ │ ├── array_copy_storage_storage_struct.sol │ │ │ ├── array_copy_storage_to_memory.sol │ │ │ ├── array_copy_storage_to_memory_nested.sol │ │ │ ├── array_copy_target_leftover.sol │ │ │ ├── array_copy_target_leftover2.sol │ │ │ ├── array_copy_target_simple.sol │ │ │ ├── array_copy_target_simple_2.sol │ │ │ ├── array_elements_to_mapping.sol │ │ │ ├── array_nested_calldata_to_memory.sol │ │ │ ├── array_nested_calldata_to_storage.sol │ │ │ ├── array_nested_memory_to_storage.sol │ │ │ ├── array_nested_storage_to_memory.sol │ │ │ ├── array_of_function_external_storage_to_storage_dynamic.sol │ │ │ ├── array_of_function_external_storage_to_storage_dynamic_different_mutability.sol │ │ │ ├── array_of_struct_calldata_to_memory.sol │ │ │ ├── array_of_struct_calldata_to_storage.sol │ │ │ ├── array_of_struct_memory_to_storage.sol │ │ │ ├── array_of_structs_containing_arrays_calldata_to_memory.sol │ │ │ ├── array_of_structs_containing_arrays_calldata_to_storage.sol │ │ │ ├── array_of_structs_containing_arrays_memory_to_storage.sol │ │ │ ├── array_storage_multi_items_per_slot.sol │ │ │ ├── array_to_mapping.sol │ │ │ ├── arrays_from_and_to_storage.sol │ │ │ ├── bytes_calldata_to_string_calldata.sol │ │ │ ├── bytes_inside_mappings.sol │ │ │ ├── bytes_memory_to_storage.sol │ │ │ ├── bytes_storage_to_memory.sol │ │ │ ├── bytes_storage_to_storage.sol │ │ │ ├── calldata_1d_array_into_2d_memory_array_element.sol │ │ │ ├── calldata_2d_bytes_to_memory.sol │ │ │ ├── calldata_2d_bytes_to_memory_2.sol │ │ │ ├── calldata_array_dynamic_to_storage.sol │ │ │ ├── calldata_array_of_struct_to_memory.sol │ │ │ ├── calldata_array_static_to_memory.sol │ │ │ ├── calldata_array_to_mapping.sol │ │ │ ├── calldata_bytes_array_to_memory.sol │ │ │ ├── calldata_bytes_to_storage.sol │ │ │ ├── calldata_dyn_2d_bytes_to_memory.sol │ │ │ ├── calldata_dynamic_array_to_memory.sol │ │ │ ├── calldata_nested_array_copy_to_memory.sol │ │ │ ├── calldata_to_storage_different_base.sol │ │ │ ├── cleanup_during_multi_element_per_slot_copy.sol │ │ │ ├── copy_byte_array_in_struct_to_storage.sol │ │ │ ├── copy_byte_array_to_storage.sol │ │ │ ├── copy_function_internal_storage_array.sol │ │ │ ├── copy_internal_function_array_to_storage.sol │ │ │ ├── copy_removes_bytes_data.sol │ │ │ ├── copying_bytes_multiassign.sol │ │ │ ├── dirty_memory_bytes_to_storage_copy.sol │ │ │ ├── dirty_memory_bytes_to_storage_copy_ir.sol │ │ │ ├── elements_of_nested_array_of_structs_calldata_to_storage.sol │ │ │ ├── elements_of_nested_array_of_structs_memory_to_storage.sol │ │ │ ├── empty_bytes_copy.sol │ │ │ ├── function_type_array_to_storage.sol │ │ │ ├── memory_dyn_2d_bytes_to_storage.sol │ │ │ ├── memory_to_storage_different_base.sol │ │ │ ├── nested_array_element_calldata_to_memory.sol │ │ │ ├── nested_array_element_calldata_to_storage.sol │ │ │ ├── nested_array_element_memory_to_memory.sol │ │ │ ├── nested_array_element_memory_to_storage.sol │ │ │ ├── nested_array_element_storage_to_memory.sol │ │ │ ├── nested_array_element_storage_to_storage.sol │ │ │ ├── nested_array_of_structs_calldata_to_memory.sol │ │ │ ├── nested_array_of_structs_calldata_to_storage.sol │ │ │ ├── nested_array_of_structs_memory_to_memory.sol │ │ │ ├── nested_array_of_structs_memory_to_storage.sol │ │ │ ├── nested_array_of_structs_storage_to_storage.sol │ │ │ ├── nested_array_of_structs_with_nested_array_from_storage_to_memory.sol │ │ │ ├── nested_dynamic_array_element_calldata_to_storage.sol │ │ │ ├── storage_memory_nested.sol │ │ │ ├── storage_memory_nested_bytes.sol │ │ │ ├── storage_memory_nested_from_pointer.sol │ │ │ ├── storage_memory_nested_struct.sol │ │ │ ├── storage_memory_packed.sol │ │ │ ├── storage_memory_packed_dyn.sol │ │ │ └── string_calldata_to_bytes_calldata.sol │ │ ├── create_dynamic_array_with_zero_length.sol │ │ ├── create_memory_array.sol │ │ ├── create_memory_array_too_large.sol │ │ ├── create_memory_byte_array.sol │ │ ├── create_multiple_dynamic_arrays.sol │ │ ├── delete │ │ │ ├── bytes_delete_element.sol │ │ │ ├── delete_bytes_array.sol │ │ │ ├── delete_memory_array.sol │ │ │ ├── delete_on_array_of_structs.sol │ │ │ ├── delete_removes_bytes_data.sol │ │ │ ├── delete_storage_array.sol │ │ │ ├── delete_storage_array_packed.sol │ │ │ └── memory_arrays_delete.sol │ │ ├── dynamic_array_cleanup.sol │ │ ├── dynamic_arrays_in_storage.sol │ │ ├── dynamic_multi_array_cleanup.sol │ │ ├── dynamic_out_of_bounds_array_access.sol │ │ ├── evm_exceptions_out_of_band_access.sol │ │ ├── external_array_args.sol │ │ ├── fixed_array_cleanup.sol │ │ ├── fixed_arrays_as_return_type.sol │ │ ├── fixed_arrays_in_constructors.sol │ │ ├── fixed_arrays_in_storage.sol │ │ ├── fixed_bytes_length_access.sol │ │ ├── fixed_out_of_bounds_array_access.sol │ │ ├── function_array_cross_calls.sol │ │ ├── function_memory_array.sol │ │ ├── indexAccess │ │ │ ├── arrays_complex_memory_index_access.sol │ │ │ ├── bytes_index_access.sol │ │ │ ├── bytes_index_access_memory.sol │ │ │ ├── bytes_memory_index_access.sol │ │ │ ├── fixed_bytes_index_access.sol │ │ │ ├── index_access.sol │ │ │ ├── inline_array_index_access_ints.sol │ │ │ ├── inline_array_index_access_strings.sol │ │ │ ├── memory_arrays_dynamic_index_access_write.sol │ │ │ └── memory_arrays_index_access_write.sol │ │ ├── inline_array_return.sol │ │ ├── inline_array_singleton.sol │ │ ├── inline_array_storage_to_memory_conversion_ints.sol │ │ ├── inline_array_storage_to_memory_conversion_strings.sol │ │ ├── inline_array_strings_from_document.sol │ │ ├── invalid_encoding_for_storage_byte_array.sol │ │ ├── memory.sol │ │ ├── memory_arrays_of_various_sizes.sol │ │ ├── pop │ │ │ ├── array_pop.sol │ │ │ ├── array_pop_array_transition.sol │ │ │ ├── array_pop_empty_exception.sol │ │ │ ├── array_pop_isolated.sol │ │ │ ├── array_pop_storage_empty.sol │ │ │ ├── array_pop_uint16_transition.sol │ │ │ ├── array_pop_uint24_transition.sol │ │ │ ├── byte_array_pop.sol │ │ │ ├── byte_array_pop_copy_long.sol │ │ │ ├── byte_array_pop_empty_exception.sol │ │ │ ├── byte_array_pop_isolated.sol │ │ │ ├── byte_array_pop_long_storage_empty.sol │ │ │ ├── byte_array_pop_long_storage_empty_garbage_ref.sol │ │ │ ├── byte_array_pop_masking_long.sol │ │ │ ├── byte_array_pop_storage_empty.sol │ │ │ └── parenthesized.sol │ │ ├── push │ │ │ ├── array_push.sol │ │ │ ├── array_push_nested.sol │ │ │ ├── array_push_nested_from_calldata.sol │ │ │ ├── array_push_nested_from_memory.sol │ │ │ ├── array_push_packed_array.sol │ │ │ ├── array_push_struct.sol │ │ │ ├── array_push_struct_from_calldata.sol │ │ │ ├── byte_array_push.sol │ │ │ ├── byte_array_push_transition.sol │ │ │ ├── nested_bytes_push.sol │ │ │ ├── push_no_args_1d.sol │ │ │ ├── push_no_args_2d.sol │ │ │ ├── push_no_args_bytes.sol │ │ │ └── push_no_args_struct.sol │ │ ├── reusing_memory.sol │ │ ├── short_fixed_array_cleanup.sol │ │ ├── slices │ │ │ ├── array_calldata_assignment.sol │ │ │ ├── array_slice_calldata_as_argument_of_external_calls.sol │ │ │ ├── array_slice_calldata_to_calldata.sol │ │ │ ├── array_slice_calldata_to_memory.sol │ │ │ └── array_slice_calldata_to_storage.sol │ │ ├── storage_array_ref.sol │ │ ├── string_allocation_bug.sol │ │ ├── string_bytes_conversion.sol │ │ ├── string_literal_assign_to_storage_bytes.sol │ │ └── strings_in_struct.sol │ │ ├── asmForLoop │ │ ├── for_loop_break.sol │ │ ├── for_loop_continue.sol │ │ └── for_loop_nested.sol │ │ ├── builtinFunctions │ │ ├── assignment_to_const_var_involving_keccak.sol │ │ ├── blobhash.sol │ │ ├── blobhash_shadow_resolution.sol │ │ ├── blockhash.sol │ │ ├── blockhash_shadow_resolution.sol │ │ ├── function_types_sig.sol │ │ ├── iterated_keccak256_with_bytes.sol │ │ ├── keccak256.sol │ │ ├── keccak256_empty.sol │ │ ├── keccak256_multiple_arguments.sol │ │ ├── keccak256_multiple_arguments_with_numeric_literals.sol │ │ ├── keccak256_multiple_arguments_with_string_literals.sol │ │ ├── keccak256_packed.sol │ │ ├── keccak256_packed_complex_types.sol │ │ ├── keccak256_with_bytes.sol │ │ ├── msg_sig.sol │ │ ├── msg_sig_after_internal_call_is_same.sol │ │ ├── ripemd160.sol │ │ ├── ripemd160_empty.sol │ │ ├── ripemd160_packed.sol │ │ ├── sha256.sol │ │ ├── sha256_empty.sol │ │ └── sha256_packed.sol │ │ ├── byte_array_to_storage_cleanup.sol │ │ ├── c99_scoping_activation.sol │ │ ├── calldata │ │ ├── calldata_array_access.sol │ │ ├── calldata_array_dynamic_bytes.sol │ │ ├── calldata_array_index_range_access.sol │ │ ├── calldata_array_length.sol │ │ ├── calldata_array_three_dimensional.sol │ │ ├── calldata_attached_to_bytes.sol │ │ ├── calldata_attached_to_dynamic_array_or_slice.sol │ │ ├── calldata_attached_to_static_array.sol │ │ ├── calldata_attached_to_struct.sol │ │ ├── calldata_bytes_array_bounds.sol │ │ ├── calldata_bytes_external.sol │ │ ├── calldata_bytes_internal.sol │ │ ├── calldata_bytes_to_memory.sol │ │ ├── calldata_bytes_to_memory_encode.sol │ │ ├── calldata_internal_function_pointer.sol │ │ ├── calldata_internal_library.sol │ │ ├── calldata_internal_multi_array.sol │ │ ├── calldata_internal_multi_fixed_array.sol │ │ ├── calldata_memory_mixed.sol │ │ ├── calldata_string_array.sol │ │ ├── calldata_struct.sol │ │ ├── calldata_struct_cleaning.sol │ │ ├── calldata_struct_internal.sol │ │ └── copy_from_calldata_removes_bytes_data.sol │ │ ├── cleanup │ │ ├── bool_conversion_v1.sol │ │ ├── bool_conversion_v2.sol │ │ ├── cleanup_address_types_shortening.sol │ │ ├── cleanup_address_types_v1.sol │ │ ├── cleanup_address_types_v2.sol │ │ ├── cleanup_bytes_types_shortening_OldCodeGen.sol │ │ ├── cleanup_bytes_types_shortening_newCodeGen.sol │ │ ├── cleanup_bytes_types_v1.sol │ │ ├── cleanup_bytes_types_v2.sol │ │ ├── cleanup_in_compound_assign.sol │ │ ├── exp_cleanup.sol │ │ ├── exp_cleanup_direct.sol │ │ ├── exp_cleanup_nonzero_base.sol │ │ ├── exp_cleanup_smaller_base.sol │ │ ├── indexed_log_topic_during_explicit_downcast.sol │ │ └── indexed_log_topic_during_explicit_downcast_during_emissions.sol │ │ ├── constantEvaluator │ │ ├── negative_fractional_mod.sol │ │ └── rounding.sol │ │ ├── constants │ │ ├── asm_address_constant_regression.sol │ │ ├── asm_constant_file_level.sol │ │ ├── constant_string.sol │ │ ├── constant_string_at_file_level.sol │ │ ├── constant_variables.sol │ │ ├── constants_at_file_level_referencing.sol │ │ ├── consteval_array_length.sol │ │ ├── function_unreferenced.sol │ │ ├── same_constants_different_files.sol │ │ └── simple_constant_variables_test.sol │ │ ├── constructor │ │ ├── constructor_inheritance_init_order.sol │ │ ├── constructor_inheritance_init_order_2.sol │ │ ├── constructor_inheritance_init_order_3_legacy.sol │ │ ├── constructor_inheritance_init_order_3_viaIR.sol │ │ ├── constructor_with_params.sol │ │ ├── constructor_with_params_diamond_inheritance.sol │ │ ├── constructor_with_params_inheritance.sol │ │ ├── constructor_with_params_inheritance_2.sol │ │ ├── conversions │ │ ├── function_type_array_to_storage.sol │ │ └── string_to_bytes.sol │ │ ├── deployedCodeExclusion │ │ ├── bound_function.sol │ │ ├── library_function.sol │ │ ├── library_function_deployed.sol │ │ ├── module_function.sol │ │ ├── module_function_deployed.sol │ │ ├── static_base_function.sol │ │ ├── static_base_function_deployed.sol │ │ ├── subassembly_deduplication.sol │ │ ├── super_function.sol │ │ ├── super_function_deployed.sol │ │ ├── virtual_function.sol │ │ └── virtual_function_deployed.sol │ │ ├── dirty_calldata_bytes.sol │ │ ├── dirty_calldata_dynamic_array.sol │ │ ├── ecrecover │ │ ├── ecrecover.sol │ │ ├── ecrecover_abiV2.sol │ │ ├── failing_ecrecover_invalid_input.sol │ │ ├── failing_ecrecover_invalid_input_asm.sol │ │ └── failing_ecrecover_invalid_input_proper.sol │ │ ├── emit_three_identical_events.sol │ │ ├── emit_two_identical_events.sol │ │ ├── empty_contract.sol │ │ ├── empty_for_loop.sol │ │ ├── enums │ │ ├── constructing_enums_from_ints.sol │ │ ├── enum_explicit_overflow.sol │ │ ├── enum_explicit_overflow_homestead.sol │ │ ├── enum_referencing.sol │ │ ├── enum_with_256_members.sol │ │ ├── invalid_enum_logged.sol │ │ ├── minmax.sol │ │ ├── using_contract_enums_with_explicit_contract_name.sol │ │ ├── using_enums.sol │ │ ├── using_inherited_enum.sol │ │ └── using_inherited_enum_excplicitly.sol │ │ ├── errors │ │ ├── error_in_library_and_interface.sol │ │ ├── error_selector.sol │ │ ├── error_static_calldata_uint_array_and_dynamic_array.sol │ │ ├── named_error_args.sol │ │ ├── named_parameters_shadowing_types.sol │ │ ├── panic_via_import.sol │ │ ├── revert_conversion.sol │ │ ├── simple.sol │ │ ├── using_structs.sol │ │ ├── via_contract_type.sol │ │ ├── via_import.sol │ │ └── weird_name.sol │ │ ├── events │ │ ├── event.sol │ │ ├── event_access_through_base_name_emit.sol │ │ ├── event_anonymous.sol │ │ ├── event_anonymous_with_signature_collision.sol │ │ ├── event_anonymous_with_signature_collision2.sol │ │ ├── event_anonymous_with_topics.sol │ │ ├── event_constructor.sol │ │ ├── event_dynamic_array_memory.sol │ │ ├── event_dynamic_array_memory_v2.sol │ │ ├── event_dynamic_array_storage.sol │ │ ├── event_dynamic_array_storage_v2.sol │ │ ├── event_dynamic_nested_array_memory_v2.sol │ │ ├── event_dynamic_nested_array_storage_v2.sol │ │ ├── event_emit.sol │ │ ├── event_emit_file_level.sol │ │ ├── event_emit_from_a_foreign_contract.sol │ │ ├── event_emit_from_a_foreign_contract_same_name.sol │ │ ├── event_emit_from_other_contract.sol │ │ ├── event_emit_interface_event_via_library.sol │ │ ├── event_emit_via_interface.sol │ │ ├── event_indexed_function.sol │ │ ├── event_indexed_function2.sol │ │ ├── event_indexed_mixed.sol │ │ ├── event_indexed_string.sol │ │ ├── event_lots_of_data.sol │ │ ├── event_no_arguments.sol │ │ ├── event_really_lots_of_data.sol │ │ ├── event_really_lots_of_data_from_storage.sol │ │ ├── event_really_really_lots_of_data_from_storage.sol │ │ ├── event_selector.sol │ │ ├── event_selector_file_level.sol │ │ ├── event_shadowing_file_level.sol │ │ ├── event_signature_in_library.sol │ │ ├── event_static_calldata_uint_array_and_dynamic_array.sol │ │ ├── event_string.sol │ │ ├── event_struct_memory_v2.sol │ │ ├── event_struct_storage_v2.sol │ │ ├── events_with_same_name.sol │ │ ├── events_with_same_name_file_level.sol │ │ ├── events_with_same_name_inherited_emit.sol │ │ └── simple.sol │ │ ├── experimental │ │ ├── stub.sol │ │ └── type_class.sol │ │ ├── exponentiation │ │ ├── literal_base.sol │ │ ├── signed_base.sol │ │ └── small_exp.sol │ │ ├── expressions │ │ ├── bit_operators.sol │ │ ├── bytes_comparison.sol │ │ ├── conditional_expression_different_types.sol │ │ ├── conditional_expression_false_literal.sol │ │ ├── conditional_expression_functions.sol │ │ ├── conditional_expression_multiple.sol │ │ ├── conditional_expression_storage_memory_1.sol │ │ ├── conditional_expression_storage_memory_2.sol │ │ ├── conditional_expression_true_literal.sol │ │ ├── conditional_expression_tuples.sol │ │ ├── conditional_expression_with_return_values.sol │ │ ├── exp_operator_const.sol │ │ ├── exp_operator_const_signed.sol │ │ ├── exp_zero_literal.sol │ │ ├── inc_dec_operators.sol │ │ ├── module_from_ternary_expression.sol │ │ ├── tuple_from_ternary_expression.sol │ │ ├── unary_too_long_literal.sol │ │ └── uncalled_address_transfer_send.sol │ │ ├── externalContracts │ │ ├── FixedFeeRegistrar.sol │ │ ├── _base64 │ │ │ ├── base64_inline_asm.sol │ │ │ └── base64_no_inline_asm.sol │ │ ├── _prbmath │ │ │ ├── LICENSE.md │ │ │ ├── PRBMathCommon.sol │ │ │ ├── PRBMathSD59x18.sol │ │ │ ├── PRBMathUD60x18.sol │ │ │ └── README.md │ │ ├── _stringutils │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ └── stringutils.sol │ │ ├── base64.sol │ │ ├── deposit_contract.sol │ │ ├── prbmath_signed.sol │ │ ├── prbmath_unsigned.sol │ │ ├── ramanujan_pi.sol │ │ ├── snark.sol │ │ └── strings.sol │ │ ├── externalSource │ │ ├── _external │ │ │ ├── external.sol │ │ │ ├── external.sol=sol │ │ │ ├── import.sol │ │ │ ├── import_with_subdir.sol │ │ │ ├── other_external.sol │ │ │ └── subdir │ │ │ │ ├── import.sol │ │ │ │ └── sub_external.sol │ │ ├── _non_normalized_paths │ │ │ ├── a.sol │ │ │ ├── c.sol │ │ │ └── d.sol │ │ ├── _relative_imports │ │ │ ├── D │ │ │ │ └── d.sol │ │ │ ├── c.sol │ │ │ ├── dir │ │ │ │ ├── B │ │ │ │ │ └── b.sol │ │ │ │ ├── G │ │ │ │ │ └── g.sol │ │ │ │ ├── a.sol │ │ │ │ └── contract.sol │ │ │ └── h.sol │ │ ├── _source_name_starting_with_dots │ │ │ ├── b.sol │ │ │ ├── dir │ │ │ │ ├── a.sol │ │ │ │ └── contract.sol │ │ │ ├── dot_a.sol │ │ │ └── dot_dot_b.sol │ │ ├── multiple_equals_signs.sol │ │ ├── multiple_external_source.sol │ │ ├── multisource.sol │ │ ├── non_normalized_paths.sol │ │ ├── relative_imports.sol │ │ ├── source.sol │ │ ├── source_import.sol │ │ ├── source_import_subdir.sol │ │ ├── source_name_starting_with_dots.sol │ │ └── source_remapping.sol │ │ ├── fallback │ │ ├── call_forward_bytes.sol │ │ ├── falback_return.sol │ │ ├── fallback_argument.sol │ │ ├── fallback_argument_to_storage.sol │ │ ├── fallback_or_receive.sol │ │ ├── fallback_override.sol │ │ ├── fallback_override2.sol │ │ ├── fallback_override_multi.sol │ │ ├── fallback_return_data.sol │ │ ├── inherited.sol │ │ └── short_data_calls_fallback.sol │ │ ├── freeFunctions │ │ ├── easy.sol │ │ ├── free_namesake_contract_function.sol │ │ ├── free_runtimecode.sol │ │ ├── import.sol │ │ ├── libraries_from_free.sol │ │ ├── new_operator.sol │ │ ├── overloads.sol │ │ ├── recursion.sol │ │ └── storage_calldata_refs.sol │ │ ├── functionCall │ │ ├── array_multiple_local_vars.sol │ │ ├── bare_call_no_returndatacopy.sol │ │ ├── call_attached_library_function_on_function.sol │ │ ├── call_attached_library_function_on_storage_variable.sol │ │ ├── call_attached_library_function_on_string.sol │ │ ├── call_function_returning_function.sol │ │ ├── call_function_returning_nothing_via_pointer.sol │ │ ├── call_internal_function_via_expression.sol │ │ ├── call_internal_function_with_multislot_arguments_via_pointer.sol │ │ ├── call_options_overload.sol │ │ ├── calling_nonexisting_contract_throws.sol │ │ ├── calling_other_functions.sol │ │ ├── calling_uninitialized_function.sol │ │ ├── calling_uninitialized_function_in_detail.sol │ │ ├── calling_uninitialized_function_through_array.sol │ │ ├── conditional_with_arguments.sol │ │ ├── creation_function_call_no_args.sol │ │ ├── creation_function_call_with_args.sol │ │ ├── creation_function_call_with_salt.sol │ │ ├── delegatecall_return_value.sol │ │ ├── delegatecall_return_value_pre_byzantium.sol │ │ ├── disordered_named_args.sol │ │ ├── external_call.sol │ │ ├── external_call_at_construction_time.sol │ │ ├── external_call_dynamic_returndata.sol │ │ ├── external_call_to_nonexisting.sol │ │ ├── external_call_to_nonexisting_debugstrings.sol │ │ ├── external_call_value.sol │ │ ├── external_function.sol │ │ ├── external_public_override.sol │ │ ├── failed_create.sol │ │ ├── file_level_call_via_module.sol │ │ ├── gas_and_value_basic.sol │ │ ├── gas_and_value_brace_syntax.sol │ │ ├── inheritance │ │ │ ├── base_base_overload.sol │ │ │ ├── base_overload.sol │ │ │ ├── call_base.sol │ │ │ ├── call_base_base.sol │ │ │ ├── call_base_base_explicit.sol │ │ │ ├── call_base_explicit.sol │ │ │ ├── call_unimplemented_base.sol │ │ │ ├── super_skip_unimplemented_in_abstract_contract.sol │ │ │ └── super_skip_unimplemented_in_interface.sol │ │ ├── mapping_array_internal_argument.sol │ │ ├── mapping_internal_argument.sol │ │ ├── mapping_internal_return.sol │ │ ├── member_accessors.sol │ │ ├── multiple_functions.sol │ │ ├── multiple_return_values.sol │ │ ├── named_args.sol │ │ ├── named_args_overload.sol │ │ ├── precompile_extcodesize_check.sol │ │ ├── return_size_bigger_than_expected.sol │ │ ├── return_size_shorter_than_expected.sol │ │ ├── return_size_shorter_than_expected_evm_version_after_homestead.sol │ │ ├── send_zero_ether.sol │ │ ├── transaction_status.sol │ │ └── value_test.sol │ │ ├── functionSelector │ │ └── function_selector_via_contract_name.sol │ │ ├── functionTypes │ │ ├── address_member.sol │ │ ├── call_to_zero_initialized_function_type_ir.sol │ │ ├── call_to_zero_initialized_function_type_legacy.sol │ │ ├── comparison_operator_for_external_function_cleans_dirty_bits.sol │ │ ├── comparison_operators_for_external_functions.sol │ │ ├── duplicated_function_definition_with_same_id_in_internal_dispatcher.sol │ │ ├── external_functions_with_calldata_args_assigned_to_function_pointers_with_memory_type.sol │ │ ├── function_delete_stack.sol │ │ ├── function_delete_storage.sol │ │ ├── function_external_delete_storage.sol │ │ ├── function_type_library_internal.sol │ │ ├── inline_array_with_value_call_option.sol │ │ ├── mapping_of_functions.sol │ │ ├── pass_function_types_externally.sol │ │ ├── pass_function_types_internally.sol │ │ ├── same_function_in_construction_and_runtime.sol │ │ ├── same_function_in_construction_and_runtime_equality_check.sol │ │ ├── selector_1.sol │ │ ├── selector_2.sol │ │ ├── selector_assignment_expression.sol │ │ ├── selector_expression_side_effect.sol │ │ ├── selector_ternary.sol │ │ ├── selector_ternary_function_pointer_from_function_call.sol │ │ ├── stack_height_check_on_adding_gas_variable_to_function.sol │ │ ├── store_function.sol │ │ ├── struct_with_external_function.sol │ │ ├── struct_with_functions.sol │ │ ├── ternary_contract_internal_function.sol │ │ ├── ternary_contract_library_internal_function.sol │ │ ├── ternary_contract_public_function.sol │ │ └── uninitialized_internal_storage_function_call.sol │ │ ├── getters │ │ ├── array_mapping_struct.sol │ │ ├── arrays.sol │ │ ├── bytes.sol │ │ ├── mapping.sol │ │ ├── mapping_array_struct.sol │ │ ├── mapping_of_string.sol │ │ ├── mapping_to_struct.sol │ │ ├── mapping_with_names.sol │ │ ├── string_and_bytes.sol │ │ ├── struct_with_bytes.sol │ │ ├── struct_with_bytes_simple.sol │ │ └── value_types.sol │ │ ├── immutable │ │ ├── assign_at_declaration.sol │ │ ├── assign_from_immutables.sol │ │ ├── delete.sol │ │ ├── fun_read_in_ctor.sol │ │ ├── getter.sol │ │ ├── getter_call_in_constructor.sol │ │ ├── immutable_signed.sol │ │ ├── increment_decrement.sol │ │ ├── inheritance.sol │ │ ├── internal_function_pointer.sol │ │ ├── multi_creation.sol │ │ ├── multiple_initializations.sol │ │ ├── read_in_ctor.sol │ │ ├── small_types_in_reverse.sol │ │ ├── stub.sol │ │ ├── uninitialized.sol │ │ └── use_scratch.sol │ │ ├── inheritance │ │ ├── access_base_storage.sol │ │ ├── address_overload_resolution.sol │ │ ├── base_access_to_function_type_variables.sol │ │ ├── dataLocation │ │ │ └── external_public_calldata.sol │ │ ├── derived_overload_base_function_direct.sol │ │ ├── derived_overload_base_function_indirect.sol │ │ ├── explicit_base_class.sol │ │ ├── inherited_constant_state_var.sol │ │ ├── inherited_function.sol │ │ ├── inherited_function_calldata_calldata_interface.sol │ │ ├── inherited_function_calldata_memory.sol │ │ ├── inherited_function_calldata_memory_interface.sol │ │ ├── inherited_function_from_a_library.sol │ │ ├── inherited_function_through_dispatch.sol │ │ ├── member_notation_ctor.sol │ │ ├── overloaded_function_call_resolve_to_first.sol │ │ ├── overloaded_function_call_resolve_to_second.sol │ │ ├── overloaded_function_call_with_if_else.sol │ │ ├── pass_dynamic_arguments_to_the_base.sol │ │ ├── pass_dynamic_arguments_to_the_base_base.sol │ │ ├── pass_dynamic_arguments_to_the_base_base_with_gap.sol │ │ ├── super_in_constructor.sol │ │ ├── super_in_constructor_assignment.sol │ │ ├── super_overload.sol │ │ └── value_for_constructor.sol │ │ ├── inlineAssembly │ │ ├── basefee_berlin_function.sol │ │ ├── blobbasefee_shanghai_function.sol │ │ ├── blobhash.sol │ │ ├── blobhash_index_exceeding_blob_count.sol │ │ ├── blobhash_pre_cancun.sol │ │ ├── calldata_array_assign_dynamic.sol │ │ ├── calldata_array_assign_static.sol │ │ ├── calldata_array_read.sol │ │ ├── calldata_assign.sol │ │ ├── calldata_assign_from_nowhere.sol │ │ ├── calldata_length_read.sol │ │ ├── calldata_offset_read.sol │ │ ├── calldata_offset_read_write.sol │ │ ├── calldata_struct_assign.sol │ │ ├── calldata_struct_assign_and_return.sol │ │ ├── chainid.sol │ │ ├── constant_access.sol │ │ ├── constant_access_referencing.sol │ │ ├── difficulty.sol │ │ ├── external_function_pointer_address.sol │ │ ├── external_function_pointer_address_assignment.sol │ │ ├── external_function_pointer_selector.sol │ │ ├── external_function_pointer_selector_assignment.sol │ │ ├── external_identifier_access_shadowing.sol │ │ ├── function_name_clash.sol │ │ ├── inline_assembly_embedded_function_call.sol │ │ ├── inline_assembly_for.sol │ │ ├── inline_assembly_for2.sol │ │ ├── inline_assembly_function_call.sol │ │ ├── inline_assembly_function_call2.sol │ │ ├── inline_assembly_function_call_assignment.sol │ │ ├── inline_assembly_if.sol │ │ ├── inline_assembly_in_modifiers.sol │ │ ├── inline_assembly_memory_access.sol │ │ ├── inline_assembly_read_and_write_stack.sol │ │ ├── inline_assembly_recursion.sol │ │ ├── inline_assembly_storage_access.sol │ │ ├── inline_assembly_storage_access_inside_function.sol │ │ ├── inline_assembly_storage_access_local_var.sol │ │ ├── inline_assembly_storage_access_via_pointer.sol │ │ ├── inline_assembly_switch.sol │ │ ├── inline_assembly_write_to_stack.sol │ │ ├── inlineasm_empty_let.sol │ │ ├── keccak256_assembly.sol │ │ ├── keccak256_optimization.sol │ │ ├── keccak256_optimizer_bug_different_memory_location.sol │ │ ├── keccak256_optimizer_cache_bug.sol │ │ ├── keccak_optimization_bug_string.sol │ │ ├── keccak_yul_optimization.sol │ │ ├── leave.sol │ │ ├── mcopy.sol │ │ ├── mcopy_as_identifier_pre_cancun.sol │ │ ├── mcopy_empty.sol │ │ ├── mcopy_overlap.sol │ │ ├── optimize_memory_store_multi_block.sol │ │ ├── optimize_memory_store_multi_block_bugreport.sol │ │ ├── prevrandao.sol │ │ ├── selfbalance.sol │ │ ├── shadowing_local_function_opcode.sol │ │ ├── slot_access.sol │ │ ├── slot_access_via_mapping_pointer.sol │ │ ├── tload_tstore_not_reserved_before_cancun.sol │ │ ├── transient_storage_creation.sol │ │ ├── transient_storage_low_level_calls.sol │ │ ├── transient_storage_multiple_calls_different_transactions.sol │ │ ├── transient_storage_multiple_transactions.sol │ │ ├── transient_storage_reset_between_creation_runtime.sol │ │ ├── transient_storage_sanity_checks.sol │ │ ├── transient_storage_selfdestruct.sol │ │ ├── transient_storage_simple_reentrancy_lock.sol │ │ ├── truefalse.sol │ │ └── tstore_hidden_staticcall.sol │ │ ├── integer │ │ ├── basic.sol │ │ ├── int.sol │ │ ├── many_local_variables.sol │ │ ├── small_signed_types.sol │ │ └── uint.sol │ │ ├── interfaceID │ │ ├── homer.sol │ │ ├── homer_interfaceId.sol │ │ ├── interfaceId_events.sol │ │ ├── interfaces.sol │ │ ├── lisa.sol │ │ └── lisa_interfaceId.sol │ │ ├── interface_inheritance_conversions.sol │ │ ├── isoltestFormatting.sol │ │ ├── isoltestTesting │ │ ├── account.sol │ │ ├── balance_other_contract.sol │ │ ├── balance_with_balance.sol │ │ ├── balance_with_balance2.sol │ │ ├── balance_without_balance.sol │ │ ├── builtins.sol │ │ ├── effects.sol │ │ ├── format_raw_string_with_control_chars.sol │ │ └── storage │ │ │ ├── storage_empty.sol │ │ │ └── storage_nonempty.sol │ │ ├── libraries │ │ ├── attached_internal_library_function_accepting_calldata.sol │ │ ├── attached_internal_library_function_returning_calldata.sol │ │ ├── attached_public_library_function_accepting_calldata.sol.sol │ │ ├── attached_public_library_function_returning_calldata.sol │ │ ├── external_call_with_function_pointer_parameter.sol │ │ ├── external_call_with_storage_array_parameter.sol │ │ ├── external_call_with_storage_mapping_parameter.sol │ │ ├── internal_call_attached_with_parentheses.sol │ │ ├── internal_call_unattached_with_parentheses.sol │ │ ├── internal_library_function.sol │ │ ├── internal_library_function_attached_to_address.sol │ │ ├── internal_library_function_attached_to_address_named_send_transfer.sol │ │ ├── internal_library_function_attached_to_array_named_pop_push.sol │ │ ├── internal_library_function_attached_to_bool.sol │ │ ├── internal_library_function_attached_to_contract.sol │ │ ├── internal_library_function_attached_to_dynamic_array.sol │ │ ├── internal_library_function_attached_to_enum.sol │ │ ├── internal_library_function_attached_to_external_function_type.sol │ │ ├── internal_library_function_attached_to_fixed_array.sol │ │ ├── internal_library_function_attached_to_fixed_bytes.sol │ │ ├── internal_library_function_attached_to_integer.sol │ │ ├── internal_library_function_attached_to_interface.sol │ │ ├── internal_library_function_attached_to_internal_function_type.sol │ │ ├── internal_library_function_attached_to_internal_function_type_named_selector.sol │ │ ├── internal_library_function_attached_to_literal.sol │ │ ├── internal_library_function_attached_to_mapping.sol │ │ ├── internal_library_function_attached_to_string_accepting_memory.sol │ │ ├── internal_library_function_attached_to_string_accepting_storage.sol │ │ ├── internal_library_function_attached_to_struct.sol │ │ ├── internal_library_function_calling_private.sol │ │ ├── internal_library_function_pointer.sol │ │ ├── internal_library_function_return_var_size.sol │ │ ├── internal_types_in_library.sol │ │ ├── library_address.sol │ │ ├── library_address_homestead.sol │ │ ├── library_address_via_module.sol │ │ ├── library_call_in_homestead.sol │ │ ├── library_delegatecall_guard_pure.sol │ │ ├── library_delegatecall_guard_view_needed.sol │ │ ├── library_delegatecall_guard_view_not_needed.sol │ │ ├── library_delegatecall_guard_view_staticcall.sol │ │ ├── library_enum_as_an_expression.sol │ │ ├── library_function_selectors.sol │ │ ├── library_function_selectors_struct.sol │ │ ├── library_references_preserve.sol │ │ ├── library_return_struct_with_mapping.sol │ │ ├── library_staticcall_delegatecall.sol │ │ ├── library_stray_values.sol │ │ ├── library_struct_as_an_expression.sol │ │ ├── mapping_arguments_in_library.sol │ │ ├── mapping_returns_in_library.sol │ │ ├── mapping_returns_in_library_named.sol │ │ ├── payable_function_calls_library.sol │ │ ├── stub.sol │ │ ├── stub_internal.sol │ │ ├── using_for_by_name.sol │ │ ├── using_for_function_on_int.sol │ │ ├── using_for_overload.sol │ │ ├── using_for_storage_structs.sol │ │ ├── using_library_mappings_public.sol │ │ ├── using_library_mappings_return.sol │ │ └── using_library_structs.sol │ │ ├── literals │ │ ├── denominations.sol │ │ ├── denominations_in_array_sizes.sol │ │ ├── escape.sol │ │ ├── ether.sol │ │ ├── fractional_denominations.sol │ │ ├── gwei.sol │ │ ├── hex_string_with_non_printable_characters.sol │ │ ├── hex_string_with_underscore.sol │ │ ├── scientific_notation.sol │ │ ├── ternary_operator_with_literal_types_overflow.sol │ │ └── wei.sol │ │ ├── memoryManagement │ │ ├── assembly_access.sol │ │ ├── memory_types_initialisation.sol │ │ ├── return_variable.sol │ │ ├── static_memory_array_allocation.sol │ │ └── struct_allocation.sol │ │ ├── metaTypes │ │ └── name_other_contract.sol │ │ ├── modifiers │ │ ├── access_through_contract_name.sol │ │ ├── access_through_module_name.sol │ │ ├── break_in_modifier.sol │ │ ├── continue_in_modifier.sol │ │ ├── evaluation_order.sol │ │ ├── function_modifier.sol │ │ ├── function_modifier_calling_functions_in_creation_context.sol │ │ ├── function_modifier_empty.sol │ │ ├── function_modifier_for_constructor.sol │ │ ├── function_modifier_library.sol │ │ ├── function_modifier_library_inheritance.sol │ │ ├── function_modifier_local_variables.sol │ │ ├── function_modifier_loop.sol │ │ ├── function_modifier_loop_viair.sol │ │ ├── function_modifier_multi_invocation.sol │ │ ├── function_modifier_multi_invocation_viair.sol │ │ ├── function_modifier_multi_with_return.sol │ │ ├── function_modifier_multiple_times.sol │ │ ├── function_modifier_multiple_times_local_vars.sol │ │ ├── function_modifier_overriding.sol │ │ ├── function_modifier_return_reference.sol │ │ ├── function_return_parameter.sol │ │ ├── function_return_parameter_complex.sol │ │ ├── modifer_recursive.sol │ │ ├── modifier_in_constructor_ice.sol │ │ ├── modifier_init_return.sol │ │ ├── modifiers_in_construction_context.sol │ │ ├── return_does_not_skip_modifier.sol │ │ ├── return_in_modifier.sol │ │ └── stacked_return_with_modifiers.sol │ │ ├── multiSource │ │ ├── circular_import.sol │ │ ├── circular_import_2.sol │ │ ├── circular_reimport.sol │ │ ├── circular_reimport_2.sol │ │ ├── free_different_interger_types.sol │ │ ├── free_function_resolution_base_contract.sol │ │ ├── free_function_resolution_override_virtual.sol │ │ ├── free_function_resolution_override_virtual_super.sol │ │ ├── free_function_resolution_override_virtual_transitive.sol │ │ ├── free_function_transitive_import.sol │ │ ├── import.sol │ │ ├── import_overloaded_function.sol │ │ ├── imported_free_function_via_alias.sol │ │ ├── imported_free_function_via_alias_direct_call.sol │ │ └── reimport_imported_function.sol │ │ ├── operators │ │ ├── compound_assign.sol │ │ ├── shifts │ │ │ ├── bitwise_shifting_constantinople.sol │ │ │ ├── bitwise_shifting_constantinople_combined.sol │ │ │ ├── bitwise_shifting_constants_constantinople.sol │ │ │ ├── shift_bytes_cleanup.sol │ │ │ ├── shift_bytes_cleanup_viaYul.sol │ │ │ ├── shift_cleanup.sol │ │ │ ├── shift_cleanup_garbled.sol │ │ │ ├── shift_constant_left.sol │ │ │ ├── shift_constant_left_assignment.sol │ │ │ ├── shift_constant_right.sol │ │ │ ├── shift_constant_right_assignment.sol │ │ │ ├── shift_left.sol │ │ │ ├── shift_left_assignment.sol │ │ │ ├── shift_left_assignment_different_type.sol │ │ │ ├── shift_left_larger_type.sol │ │ │ ├── shift_left_uint32.sol │ │ │ ├── shift_left_uint8.sol │ │ │ ├── shift_negative_constant_left.sol │ │ │ ├── shift_negative_constant_right.sol │ │ │ ├── shift_overflow.sol │ │ │ ├── shift_right.sol │ │ │ ├── shift_right_assignment.sol │ │ │ ├── shift_right_garbled_signed_v1.sol │ │ │ ├── shift_right_garbled_signed_v2.sol │ │ │ ├── shift_right_garbled_v1.sol │ │ │ ├── shift_right_garbled_v2.sol │ │ │ ├── shift_right_negative_literal.sol │ │ │ ├── shift_right_negative_lvalue.sol │ │ │ ├── shift_right_negative_lvalue_assignment.sol │ │ │ ├── shift_right_negative_lvalue_int16.sol │ │ │ ├── shift_right_negative_lvalue_int32.sol │ │ │ ├── shift_right_negative_lvalue_int8.sol │ │ │ ├── shift_right_negative_lvalue_signextend_int16_v1.sol │ │ │ ├── shift_right_negative_lvalue_signextend_int16_v2.sol │ │ │ ├── shift_right_negative_lvalue_signextend_int32_v1.sol │ │ │ ├── shift_right_negative_lvalue_signextend_int32_v2.sol │ │ │ ├── shift_right_negative_lvalue_signextend_int8_v1.sol │ │ │ ├── shift_right_negative_lvalue_signextend_int8_v2.sol │ │ │ ├── shift_right_uint32.sol │ │ │ ├── shift_right_uint8.sol │ │ │ ├── shift_underflow_negative_rvalue.sol │ │ │ └── shifts.sol │ │ └── userDefined │ │ │ ├── all_possible_operators.sol │ │ │ ├── all_possible_user_defined_value_types_with_operators.sol │ │ │ ├── attaching_and_defining_operator_with_same_function.sol │ │ │ ├── checked_operators.sol │ │ │ ├── consecutive_operator_invocations.sol │ │ │ ├── fixed_point_udvt_with_operators.sol │ │ │ ├── multiple_operator_definitions_different_types_different_functions_separate_directives.sol │ │ │ ├── multiple_operator_definitions_same_type_same_function_same_directive.sol │ │ │ ├── operator_definition_shadowing_builtin_keccak256.sol │ │ │ ├── operator_evaluation_order.sol │ │ │ ├── operator_making_pure_external_call.sol │ │ │ ├── operator_making_view_external_call.sol │ │ │ ├── operator_parameter_and_return_cleanup_between_calls.sol │ │ │ ├── operator_parameter_cleanup.sol │ │ │ ├── operator_precendence.sol │ │ │ ├── operator_return_parameter_cleanup.sol │ │ │ ├── recursive_operator.sol │ │ │ └── unchecked_operators.sol │ │ ├── optimizer │ │ └── shift_bytes.sol │ │ ├── payable │ │ └── no_nonpayable_circumvention_by_modifier.sol │ │ ├── receive │ │ ├── empty_calldata_calls_receive.sol │ │ ├── ether_and_data.sol │ │ └── inherited.sol │ │ ├── revertStrings │ │ ├── array_slices.sol │ │ ├── bubble.sol │ │ ├── calldata_array_dynamic_invalid.sol │ │ ├── calldata_array_dynamic_static_short_decode.sol │ │ ├── calldata_array_dynamic_static_short_reencode.sol │ │ ├── calldata_array_invalid_length.sol │ │ ├── calldata_arrays_too_large.sol │ │ ├── calldata_tail_short.sol │ │ ├── calldata_too_short_v1.sol │ │ ├── called_contract_has_code.sol │ │ ├── empty_v1.sol │ │ ├── empty_v2.sol │ │ ├── enum_v1.sol │ │ ├── enum_v2.sol │ │ ├── ether_non_payable_function.sol │ │ ├── function_entry_checks_v1.sol │ │ ├── function_entry_checks_v2.sol │ │ ├── invalid_abi_decoding_calldata_v1.sol │ │ ├── invalid_abi_decoding_memory_v1.sol │ │ ├── library_non_view_call.sol │ │ ├── short_input_array.sol │ │ ├── short_input_bytes.sol │ │ ├── transfer.sol │ │ └── unknown_sig_no_fallback.sol │ │ ├── reverts │ │ ├── assert_require.sol │ │ ├── error_struct.sol │ │ ├── invalid_enum_as_external_arg.sol │ │ ├── invalid_enum_as_external_ret.sol │ │ ├── invalid_enum_compared.sol │ │ ├── invalid_enum_stored.sol │ │ ├── invalid_instruction.sol │ │ ├── revert.sol │ │ ├── revert_return_area.sol │ │ └── simple_throw.sol │ │ ├── salted_create │ │ ├── prediction_example.sol │ │ ├── salted_create.sol │ │ └── salted_create_with_value.sol │ │ ├── shanghai │ │ ├── evmone_support.sol │ │ └── push0.sol │ │ ├── smoke │ │ ├── alignment.sol │ │ ├── arrays.sol │ │ ├── basic.sol │ │ ├── bytes_and_strings.sol │ │ ├── constructor.sol │ │ ├── failure.sol │ │ ├── fallback.sol │ │ ├── multiline.sol │ │ ├── multiline_comments.sol │ │ └── structs.sol │ │ ├── specialFunctions │ │ ├── abi_encode_with_signature_from_string.sol │ │ ├── abi_functions_member_access.sol │ │ └── keccak256_optimized.sol │ │ ├── state │ │ ├── blobhash.sol │ │ ├── block_basefee.sol │ │ ├── block_blobbasefee.sol │ │ ├── block_chainid.sol │ │ ├── block_coinbase.sol │ │ ├── block_difficulty.sol │ │ ├── block_difficulty_post_paris.sol │ │ ├── block_gaslimit.sol │ │ ├── block_number.sol │ │ ├── block_prevrandao.sol │ │ ├── block_prevrandao_pre_paris.sol │ │ ├── block_timestamp.sol │ │ ├── blockhash_basic.sol │ │ ├── gasleft.sol │ │ ├── msg_data.sol │ │ ├── msg_sender.sol │ │ ├── msg_sig.sol │ │ ├── msg_value.sol │ │ ├── tx_gasprice.sol │ │ ├── tx_origin.sol │ │ ├── uncalled_blobhash.sol │ │ └── uncalled_blockhash.sol │ │ ├── state_var_initialization.sol │ │ ├── state_variables_init_order.sol │ │ ├── state_variables_init_order_2.sol │ │ ├── state_variables_init_order_3.sol │ │ ├── statements │ │ └── do_while_loop_continue.sol │ │ ├── storage │ │ ├── accessors_mapping_for_array.sol │ │ ├── array_accessor.sol │ │ ├── chop_sign_bits.sol │ │ ├── complex_accessors.sol │ │ ├── empty_nonempty_empty.sol │ │ ├── mapping_state.sol │ │ ├── mapping_string_key.sol │ │ ├── mappings_array2d_pop_delete.sol │ │ ├── mappings_array_pop_delete.sol │ │ ├── packed_functions.sol │ │ ├── packed_storage_overflow.sol │ │ ├── packed_storage_signed.sol │ │ ├── packed_storage_structs_bytes.sol │ │ ├── packed_storage_structs_enum.sol │ │ ├── packed_storage_structs_uint.sol │ │ ├── simple_accessor.sol │ │ ├── state_smoke_test.sol │ │ └── struct_accessor.sol │ │ ├── strings │ │ ├── concat │ │ │ ├── string_concat_2_args.sol │ │ │ ├── string_concat_different_types.sol │ │ │ ├── string_concat_empty_argument_list.sol │ │ │ ├── string_concat_empty_strings.sol │ │ │ └── string_concat_nested.sol │ │ ├── constant_string_literal.sol │ │ ├── empty_storage_string.sol │ │ ├── empty_string.sol │ │ ├── empty_string_input.sol │ │ ├── return_string.sol │ │ ├── string_escapes.sol │ │ ├── unicode_escapes.sol │ │ └── unicode_string.sol │ │ ├── structs │ │ ├── array_of_recursive_struct.sol │ │ ├── calldata │ │ │ ├── calldata_nested_structs.sol │ │ │ ├── calldata_struct.sol │ │ │ ├── calldata_struct_and_ints.sol │ │ │ ├── calldata_struct_array_member.sol │ │ │ ├── calldata_struct_array_member_dynamic.sol │ │ │ ├── calldata_struct_as_argument_of_lib_function.sol │ │ │ ├── calldata_struct_as_memory_argument.sol │ │ │ ├── calldata_struct_struct_member.sol │ │ │ ├── calldata_struct_struct_member_dynamic.sol │ │ │ ├── calldata_struct_to_memory.sol │ │ │ ├── calldata_struct_to_memory_tuple_assignment.sol │ │ │ ├── calldata_struct_to_storage.sol │ │ │ ├── calldata_struct_with_array_to_memory.sol │ │ │ ├── calldata_struct_with_bytes_to_memory.sol │ │ │ ├── calldata_struct_with_nested_array_to_memory.sol │ │ │ ├── calldata_struct_with_nested_array_to_storage.sol │ │ │ ├── calldata_structs.sol │ │ │ ├── dynamic_nested.sol │ │ │ └── dynamically_encoded.sol │ │ ├── conversion │ │ │ ├── recursive_storage_memory.sol │ │ │ └── recursive_storage_memory_complex.sol │ │ ├── copy_from_mapping.sol │ │ ├── copy_from_storage.sol │ │ ├── copy_struct_array_from_storage.sol │ │ ├── copy_struct_with_nested_array_from_calldata_to_memory.sol │ │ ├── copy_struct_with_nested_array_from_calldata_to_storage.sol │ │ ├── copy_struct_with_nested_array_from_memory_to_memory.sol │ │ ├── copy_struct_with_nested_array_from_storage_to_storage.sol │ │ ├── copy_substructures_from_mapping.sol │ │ ├── copy_substructures_to_mapping.sol │ │ ├── copy_to_mapping.sol │ │ ├── delete_struct.sol │ │ ├── event.sol │ │ ├── function_type_copy.sol │ │ ├── global.sol │ │ ├── lone_struct_array_type.sol │ │ ├── memory_struct_named_constructor.sol │ │ ├── memory_structs_as_function_args.sol │ │ ├── memory_structs_nested.sol │ │ ├── memory_structs_nested_load.sol │ │ ├── memory_structs_read_write.sol │ │ ├── msg_data_to_struct_member_copy.sol │ │ ├── multislot_struct_allocation.sol │ │ ├── nested_struct_allocation.sol │ │ ├── packed_storage_structs_delete.sol │ │ ├── recursive_struct_2.sol │ │ ├── recursive_structs.sol │ │ ├── simple_struct_allocation.sol │ │ ├── struct_assign_reference_to_struct.sol │ │ ├── struct_constructor_nested.sol │ │ ├── struct_containing_bytes_copy_and_delete.sol │ │ ├── struct_copy.sol │ │ ├── struct_copy_via_local.sol │ │ ├── struct_delete_member.sol │ │ ├── struct_delete_storage.sol │ │ ├── struct_delete_storage_nested_small.sol │ │ ├── struct_delete_storage_small.sol │ │ ├── struct_delete_storage_with_array.sol │ │ ├── struct_delete_storage_with_arrays_small.sol │ │ ├── struct_delete_struct_in_mapping.sol │ │ ├── struct_memory_to_storage.sol │ │ ├── struct_memory_to_storage_function_ptr.sol │ │ ├── struct_named_constructor.sol │ │ ├── struct_reference.sol │ │ ├── struct_referencing.sol │ │ ├── struct_storage_push_zero_value.sol │ │ ├── struct_storage_to_mapping.sol │ │ ├── struct_storage_to_memory.sol │ │ ├── struct_storage_to_memory_function_ptr.sol │ │ ├── structs.sol │ │ └── using_for_function_on_struct.sol │ │ ├── tryCatch │ │ ├── assert.sol │ │ ├── create.sol │ │ ├── invalid_error_encoding.sol │ │ ├── lowLevel.sol │ │ ├── malformed_error.sol │ │ ├── malformed_panic.sol │ │ ├── malformed_panic_2.sol │ │ ├── malformed_panic_3.sol │ │ ├── malformed_panic_4.sol │ │ ├── nested.sol │ │ ├── panic.sol │ │ ├── return_function.sol │ │ ├── simple.sol │ │ ├── simple_notuple.sol │ │ ├── structured.sol │ │ ├── structuredAndLowLevel.sol │ │ ├── super_trivial.sol │ │ ├── trivial.sol │ │ └── try_catch_library_call.sol │ │ ├── types │ │ ├── array_mapping_abstract_constructor_param.sol │ │ ├── assign_calldata_value_type.sol │ │ ├── convert_fixed_bytes_to_fixed_bytes_greater_size.sol │ │ ├── convert_fixed_bytes_to_fixed_bytes_same_size.sol │ │ ├── convert_fixed_bytes_to_fixed_bytes_smaller_size.sol │ │ ├── convert_fixed_bytes_to_uint_greater_size.sol │ │ ├── convert_fixed_bytes_to_uint_same_min_size.sol │ │ ├── convert_fixed_bytes_to_uint_same_type.sol │ │ ├── convert_fixed_bytes_to_uint_smaller_size.sol │ │ ├── convert_uint_to_fixed_bytes_greater_size.sol │ │ ├── convert_uint_to_fixed_bytes_same_min_size.sol │ │ ├── convert_uint_to_fixed_bytes_same_size.sol │ │ ├── convert_uint_to_fixed_bytes_smaller_size.sol │ │ ├── external_function_to_address.sol │ │ ├── mapping │ │ │ ├── copy_from_mapping_to_mapping.sol │ │ │ ├── copy_struct_to_array_stored_in_mapping.sol │ │ │ └── user_defined_types_mapping_storage.sol │ │ ├── mapping_abstract_constructor_param.sol │ │ ├── mapping_contract_key.sol │ │ ├── mapping_contract_key_getter.sol │ │ ├── mapping_contract_key_library.sol │ │ ├── mapping_enum_key_getter_v1.sol │ │ ├── mapping_enum_key_getter_v2.sol │ │ ├── mapping_enum_key_library_v1.sol │ │ ├── mapping_enum_key_library_v2.sol │ │ ├── mapping_enum_key_v1.sol │ │ ├── mapping_enum_key_v2.sol │ │ ├── mapping_simple.sol │ │ ├── nested_tuples.sol │ │ ├── packing_signed_types.sol │ │ ├── packing_unpacking_types.sol │ │ ├── strings.sol │ │ ├── struct_mapping_abstract_constructor_param.sol │ │ ├── tuple_assign_multi_slot_grow.sol │ │ └── type_conversion_cleanup.sol │ │ ├── underscore │ │ └── as_function.sol │ │ ├── uninitializedFunctionPointer │ │ ├── invalidInConstructor.sol │ │ ├── invalidStoredInConstructor.sol │ │ ├── store2.sol │ │ ├── storeInConstructor.sol │ │ ├── uninitialized_internal_storage_function_legacy.sol │ │ └── uninitialized_internal_storage_function_via_yul.sol │ │ ├── unused_store_storage_removal_bug.sol │ │ ├── userDefinedValueType │ │ ├── abicodec.sol │ │ ├── assembly_access_bytes2_abicoder_v1.sol │ │ ├── assembly_access_bytes2_abicoder_v2.sol │ │ ├── calldata.sol │ │ ├── calldata_to_storage.sol │ │ ├── cleanup.sol │ │ ├── cleanup_abicoderv1.sol │ │ ├── constant.sol │ │ ├── conversion.sol │ │ ├── conversion_abicoderv1.sol │ │ ├── dirty_slot.sol │ │ ├── dirty_uint8_read.sol │ │ ├── erc20.sol │ │ ├── fixedpoint.sol │ │ ├── immutable_signed.sol │ │ ├── in_parenthesis.sol │ │ ├── mapping_key.sol │ │ ├── memory_to_storage.sol │ │ ├── multisource.sol │ │ ├── multisource_module.sol │ │ ├── ownable.sol │ │ ├── parameter.sol │ │ ├── simple.sol │ │ ├── storage_layout.sol │ │ ├── storage_layout_struct.sol │ │ ├── storage_signed.sol │ │ ├── wrap_unwrap.sol │ │ ├── wrap_unwrap_via_contract_name.sol │ │ ├── zero_cost_abstraction_comparison_elementary.sol │ │ └── zero_cost_abstraction_comparison_userdefined.sol │ │ ├── using │ │ ├── calldata_memory_copy.sol │ │ ├── free_function_braces.sol │ │ ├── free_function_multi.sol │ │ ├── free_functions_individual.sol │ │ ├── imported_functions.sol │ │ ├── library_functions_inside_contract.sol │ │ ├── library_on_interface.sol │ │ ├── library_through_module.sol │ │ ├── module_renamed.sol │ │ ├── private_library_function.sol │ │ ├── recursive_import.sol │ │ ├── using_global_all_the_types.sol │ │ ├── using_global_for_global.sol │ │ ├── using_global_invisible.sol │ │ └── using_global_library.sol │ │ ├── variables │ │ ├── delete_local.sol │ │ ├── delete_locals.sol │ │ ├── mapping_local_assignment.sol │ │ ├── mapping_local_compound_assignment.sol │ │ ├── mapping_local_tuple_assignment.sol │ │ ├── public_state_overridding.sol │ │ ├── public_state_overridding_dynamic_struct.sol │ │ ├── public_state_overridding_mapping_to_dynamic_struct.sol │ │ └── storing_invalid_boolean.sol │ │ ├── various │ │ ├── address_code.sol │ │ ├── address_code_complex.sol │ │ ├── assignment_to_const_var_involving_expression.sol │ │ ├── balance.sol │ │ ├── byte_optimization_bug.sol │ │ ├── code_access_content.sol │ │ ├── code_access_create.sol │ │ ├── code_access_padding.sol │ │ ├── code_access_runtime.sol │ │ ├── code_length.sol │ │ ├── code_length_contract_member.sol │ │ ├── codebalance_assembly.sol │ │ ├── codehash.sol │ │ ├── codehash_assembly.sol │ │ ├── contract_binary_dependencies.sol │ │ ├── crazy_elementary_typenames_on_stack.sol │ │ ├── create_calldata.sol │ │ ├── create_random.sol │ │ ├── cross_contract_types.sol │ │ ├── decayed_tuple.sol │ │ ├── destructuring_assignment.sol │ │ ├── empty_name_return_parameter.sol │ │ ├── erc20.sol │ │ ├── external_types_in_calls.sol │ │ ├── flipping_sign_tests.sol │ │ ├── gasleft_decrease.sol │ │ ├── gasleft_shadow_resolution.sol │ │ ├── inline_member_init.sol │ │ ├── inline_member_init_inheritence.sol │ │ ├── inline_tuple_with_rational_numbers.sol │ │ ├── iszero_bnot_correct.sol │ │ ├── literal_empty_string.sol │ │ ├── many_subassemblies.sol │ │ ├── memory_overwrite.sol │ │ ├── multi_modifiers.sol │ │ ├── multi_variable_declaration.sol │ │ ├── negative_stack_height.sol │ │ ├── nested_calldata_struct.sol │ │ ├── nested_calldata_struct_to_memory.sol │ │ ├── positive_integers_to_signed.sol │ │ ├── selfdestruct_post_cancun.sol │ │ ├── selfdestruct_post_cancun_multiple_beneficiaries.sol │ │ ├── selfdestruct_post_cancun_redeploy.sol │ │ ├── selfdestruct_pre_cancun.sol │ │ ├── selfdestruct_pre_cancun_multiple_beneficiaries.sol │ │ ├── selfdestruct_pre_cancun_redeploy.sol │ │ ├── senders_balance.sol │ │ ├── single_copy_with_multiple_inheritance.sol │ │ ├── skip_dynamic_types.sol │ │ ├── skip_dynamic_types_for_static_arrays_with_dynamic_elements.sol │ │ ├── skip_dynamic_types_for_structs.sol │ │ ├── state_variable_local_variable_mixture.sol │ │ ├── state_variable_under_contract_name.sol │ │ ├── staticcall_for_view_and_pure.sol │ │ ├── staticcall_for_view_and_pure_pre_byzantium.sol │ │ ├── storage_string_as_mapping_key_without_variable.sol │ │ ├── store_bytes.sol │ │ ├── string_tuples.sol │ │ ├── super.sol │ │ ├── super_alone.sol │ │ ├── super_parentheses.sol │ │ ├── swap_in_storage_overwrite.sol │ │ ├── test_underscore_in_hex.sol │ │ ├── tuples.sol │ │ ├── typed_multi_variable_declaration.sol │ │ ├── value_complex.sol │ │ ├── value_insane.sol │ │ └── write_storage_external.sol │ │ ├── viaYul │ │ ├── assert.sol │ │ ├── assert_and_require.sol │ │ ├── assign_tuple_from_function_call.sol │ │ ├── cleanup │ │ │ ├── checked_arithmetic.sol │ │ │ └── comparison.sol │ │ ├── comparison.sol │ │ ├── comparison_functions.sol │ │ ├── conditional │ │ │ ├── conditional_multiple.sol │ │ │ ├── conditional_true_false_literal.sol │ │ │ ├── conditional_tuple.sol │ │ │ ├── conditional_with_assignment.sol │ │ │ └── conditional_with_variables.sol │ │ ├── conversion │ │ │ ├── explicit_cast_assignment.sol │ │ │ ├── explicit_cast_function_call.sol │ │ │ ├── explicit_cast_local_assignment.sol │ │ │ ├── explicit_string_bytes_calldata_cast.sol │ │ │ ├── function_cast.sol │ │ │ ├── implicit_cast_assignment.sol │ │ │ ├── implicit_cast_function_call.sol │ │ │ └── implicit_cast_local_assignment.sol │ │ ├── copy_struct_invalid_ir_bug.sol │ │ ├── define_tuple_from_function_call.sol │ │ ├── delete.sol │ │ ├── detect_add_overflow.sol │ │ ├── detect_add_overflow_signed.sol │ │ ├── detect_div_overflow.sol │ │ ├── detect_mod_zero.sol │ │ ├── detect_mod_zero_signed.sol │ │ ├── detect_mul_overflow.sol │ │ ├── detect_mul_overflow_signed.sol │ │ ├── detect_sub_overflow.sol │ │ ├── detect_sub_overflow_signed.sol │ │ ├── dirty_calldata_struct.sol │ │ ├── dirty_memory_dynamic_array.sol │ │ ├── dirty_memory_int32.sol │ │ ├── dirty_memory_static_array.sol │ │ ├── dirty_memory_struct.sol │ │ ├── dirty_memory_uint32.sol │ │ ├── empty_return_corrupted_free_memory_pointer.sol │ │ ├── exp.sol │ │ ├── exp_literals.sol │ │ ├── exp_literals_success.sol │ │ ├── exp_neg.sol │ │ ├── exp_neg_overflow.sol │ │ ├── exp_overflow.sol │ │ ├── exp_various.sol │ │ ├── function_address.sol │ │ ├── function_entry_checks.sol │ │ ├── function_pointers.sol │ │ ├── function_selector.sol │ │ ├── if.sol │ │ ├── keccak.sol │ │ ├── local_address_assignment.sol │ │ ├── local_assignment.sol │ │ ├── local_bool_assignment.sol │ │ ├── local_tuple_assignment.sol │ │ ├── local_variable_without_init.sol │ │ ├── loops │ │ │ ├── break.sol │ │ │ ├── continue.sol │ │ │ ├── return.sol │ │ │ └── simple.sol │ │ ├── mapping_enum_key_getter.sol │ │ ├── mapping_getters.sol │ │ ├── mapping_string_key.sol │ │ ├── memory_struct_allow.sol │ │ ├── msg_sender.sol │ │ ├── negation_bug.sol │ │ ├── require.sol │ │ ├── return.sol │ │ ├── return_and_convert.sol │ │ ├── return_storage_pointers.sol │ │ ├── short_circuit.sol │ │ ├── simple_assignment.sol │ │ ├── simple_inline_asm.sol │ │ ├── smoke_test.sol │ │ ├── storage │ │ │ ├── dirty_storage_bytes.sol │ │ │ ├── dirty_storage_bytes_long.sol │ │ │ ├── dirty_storage_dynamic_array.sol │ │ │ ├── dirty_storage_static_array.sol │ │ │ ├── dirty_storage_struct.sol │ │ │ ├── mappings.sol │ │ │ ├── packed_storage.sol │ │ │ └── simple_storage.sol │ │ ├── string_format.sol │ │ ├── string_literals.sol │ │ ├── struct_member_access.sol │ │ ├── tuple_evaluation_order.sol │ │ ├── unary_fixedbytes.sol │ │ ├── unary_operations.sol │ │ ├── various_inline_asm.sol │ │ └── virtual_functions.sol │ │ └── virtualFunctions │ │ ├── internal_virtual_function_calls.sol │ │ ├── internal_virtual_function_calls_through_dispatch.sol │ │ ├── virtual_function_calls.sol │ │ ├── virtual_function_usage_in_constructor_arguments.sol │ │ ├── virtual_override_changing_mutability_internal.sol │ │ └── virtual_override_changing_mutability_public.sol ├── tuple_ternary_rhs.sol ├── type_tests │ ├── ErrorSelector.sol │ ├── HierarchyFunctions.sol │ ├── basic_types.sol │ ├── float_type.sol │ ├── function_call_types.sol │ ├── inline_array_type.sol │ ├── missing_member.sol │ └── ternary.sol ├── undefined_var.sol ├── using_directives │ ├── DefinedInSameScope.sol │ ├── FreeFunctions.sol │ ├── ImportableUser.sol │ ├── NoInheritedUsing.sol │ ├── OverloadedFunctions.sol │ ├── OverrideTypeDifferent.sol │ ├── TestImportableUser.sol │ ├── UsingDirectiveNormal.sol │ ├── UsingUnimportedAttachments.sol │ ├── UsingUnimportedAttachmentsStub.sol │ ├── UsingUnimportedAttachmentsStubB.sol │ └── UsingWithLibrary.sol └── weirdcases │ ├── empty_hex_literal.sol │ ├── function_value_option.sol │ ├── pre_constructor_keyword.sol │ ├── qualified_toplevel_type.sol │ ├── recursive_symtab.sol │ ├── ternary_assign_prec.sol │ ├── type_args.sol │ └── using_stmt_with_proxied_target_type.sol └── vendor └── antlr-4.11.1-complete.jar /docrequirements.txt: -------------------------------------------------------------------------------- 1 | sphinx==7.3.7 2 | furo==2024.1.29 3 | sphinx-autoapi==3.0.0 4 | sphinx_autodoc_typehints==2.1.0 -------------------------------------------------------------------------------- /docs/imgs/astmods2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zellic/solidity-parser/102cf4626f6be2a1cf86ef449ac2aa897ac3c2c8/docs/imgs/astmods2.png -------------------------------------------------------------------------------- /docs/imgs/exampledir.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zellic/solidity-parser/102cf4626f6be2a1cf86ef449ac2aa897ac3c2c8/docs/imgs/exampledir.png -------------------------------------------------------------------------------- /docs/imgs/gptdir.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zellic/solidity-parser/102cf4626f6be2a1cf86ef449ac2aa897ac3c2c8/docs/imgs/gptdir.png -------------------------------------------------------------------------------- /docs/imgs/parseTree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zellic/solidity-parser/102cf4626f6be2a1cf86ef449ac2aa897ac3c2c8/docs/imgs/parseTree.png -------------------------------------------------------------------------------- /docs/imgs/sourceunits.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zellic/solidity-parser/102cf4626f6be2a1cf86ef449ac2aa897ac3c2c8/docs/imgs/sourceunits.png -------------------------------------------------------------------------------- /docs/imgs/toplevelunits.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zellic/solidity-parser/102cf4626f6be2a1cf86ef449ac2aa897ac3c2c8/docs/imgs/toplevelunits.png -------------------------------------------------------------------------------- /docs/source/getstarted/index.rst: -------------------------------------------------------------------------------- 1 | Getting Started 2 | =============== 3 | 4 | .. toctree:: 5 | :maxdepth: 1 6 | 7 | prereq 8 | clients 9 | quickstart 10 | twoASTs 11 | sourcecode 12 | scopes 13 | vfshooks 14 | -------------------------------------------------------------------------------- /example/librarycall/AdderLib.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.0; 3 | 4 | library Adder { 5 | function add(uint256 a, uint256 b) public pure returns (uint256) { 6 | return a + b; 7 | } 8 | } -------------------------------------------------------------------------------- /example/project/contracts/FloatingFunc.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.8.0; 2 | 3 | error SafeCast__NegativeValue(); 4 | 5 | library IntHelper { 6 | function toUint256(int256 value) internal pure returns (uint256) { 7 | if (value < 0) revert SafeCast__NegativeValue(); 8 | return uint256(value); 9 | } 10 | } -------------------------------------------------------------------------------- /example/project/remappings.txt: -------------------------------------------------------------------------------- 1 | @openzeppelin/=lib/oz/ -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | --index-url https://pypi.python.org/simple/ 2 | 3 | -e . -------------------------------------------------------------------------------- /src/solidity_parser/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zellic/solidity-parser/102cf4626f6be2a1cf86ef449ac2aa897ac3c2c8/src/solidity_parser/__init__.py -------------------------------------------------------------------------------- /src/solidity_parser/ast/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zellic/solidity-parser/102cf4626f6be2a1cf86ef449ac2aa897ac3c2c8/src/solidity_parser/ast/__init__.py -------------------------------------------------------------------------------- /src/solidity_parser/ast/parsers/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zellic/solidity-parser/102cf4626f6be2a1cf86ef449ac2aa897ac3c2c8/src/solidity_parser/ast/parsers/__init__.py -------------------------------------------------------------------------------- /src/solidity_parser/collectors/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zellic/solidity-parser/102cf4626f6be2a1cf86ef449ac2aa897ac3c2c8/src/solidity_parser/collectors/__init__.py -------------------------------------------------------------------------------- /src/solidity_parser/grammar/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zellic/solidity-parser/102cf4626f6be2a1cf86ef449ac2aa897ac3c2c8/src/solidity_parser/grammar/__init__.py -------------------------------------------------------------------------------- /src/solidity_parser/grammar/v060/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zellic/solidity-parser/102cf4626f6be2a1cf86ef449ac2aa897ac3c2c8/src/solidity_parser/grammar/v060/__init__.py -------------------------------------------------------------------------------- /src/solidity_parser/grammar/v070/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zellic/solidity-parser/102cf4626f6be2a1cf86ef449ac2aa897ac3c2c8/src/solidity_parser/grammar/v070/__init__.py -------------------------------------------------------------------------------- /src/solidity_parser/grammar/v080/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zellic/solidity-parser/102cf4626f6be2a1cf86ef449ac2aa897ac3c2c8/src/solidity_parser/grammar/v080/__init__.py -------------------------------------------------------------------------------- /src/solidity_parser/grammar/v088/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zellic/solidity-parser/102cf4626f6be2a1cf86ef449ac2aa897ac3c2c8/src/solidity_parser/grammar/v088/__init__.py -------------------------------------------------------------------------------- /src/solidity_parser/grammar/v08_22/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zellic/solidity-parser/102cf4626f6be2a1cf86ef449ac2aa897ac3c2c8/src/solidity_parser/grammar/v08_22/__init__.py -------------------------------------------------------------------------------- /src/solidity_parser/util/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zellic/solidity-parser/102cf4626f6be2a1cf86ef449ac2aa897ac3c2c8/src/solidity_parser/util/__init__.py -------------------------------------------------------------------------------- /test/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zellic/solidity-parser/102cf4626f6be2a1cf86ef449ac2aa897ac3c2c8/test/__init__.py -------------------------------------------------------------------------------- /test/solidity_parser/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zellic/solidity-parser/102cf4626f6be2a1cf86ef449ac2aa897ac3c2c8/test/solidity_parser/__init__.py -------------------------------------------------------------------------------- /test/solidity_parser/ast/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zellic/solidity-parser/102cf4626f6be2a1cf86ef449ac2aa897ac3c2c8/test/solidity_parser/ast/__init__.py -------------------------------------------------------------------------------- /test/solidity_parser/ast/snapshots/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zellic/solidity-parser/102cf4626f6be2a1cf86ef449ac2aa897ac3c2c8/test/solidity_parser/ast/snapshots/__init__.py -------------------------------------------------------------------------------- /testcases/08_22/NegOperator.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.22; 3 | 4 | type Int is int; 5 | 6 | function myNeg(Int a) pure returns (Int) { 7 | return Int.wrap(-Int.unwrap(a)); 8 | } 9 | 10 | using {myNeg as -} for Int global; 11 | 12 | function test_neg(Int x) pure { 13 | Int z = -x; 14 | } -------------------------------------------------------------------------------- /testcases/08_22/NegOperatorNotEnoughArgs.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.22; 3 | 4 | type Int is int; 5 | 6 | function myNeg(Int a) pure returns (Int) { 7 | return Int.wrap(-Int.unwrap(a)); 8 | } 9 | 10 | using {myNeg as -} for Int global; 11 | 12 | function test_neg(Int x, Int y) pure { 13 | Int z = x - y; // invalid, 2 args for 1 arg func 14 | } -------------------------------------------------------------------------------- /testcases/08_22/OperatorAttachAndBindFailureCase.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.22; 3 | 4 | import {Int} from "./OperatorAttachAndBind.sol"; 5 | 6 | function test_invalid(Int x, Int y) pure { 7 | x.add(y); // ERROR: Member "add" not found or not visible after argument-dependent lookup in Int. 8 | } -------------------------------------------------------------------------------- /testcases/08_22/OperatorAttachAndBindWithImport.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.22; 3 | 4 | import {Int} from "./OperatorAttachAndBind.sol"; 5 | 6 | function test_valid(Int x, Int y) pure returns (Int) { 7 | return x + y; 8 | } -------------------------------------------------------------------------------- /testcases/08_22/SourceUnits.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.8.22; 2 | 3 | // Event def and using allowed at top level of file 4 | 5 | event Approval(address indexed owner, address indexed spender, uint256 value); 6 | 7 | -------------------------------------------------------------------------------- /testcases/imports/ImportA.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.8.8; 2 | 3 | library OwnableStorage { 4 | struct Layout { 5 | address owner; 6 | } 7 | 8 | function layout() internal pure returns (Layout storage l) { 9 | Layout storage l; 10 | return l; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/abstract_contract.sol: -------------------------------------------------------------------------------- 1 | abstract contract C { 2 | constructor() { 3 | } 4 | } 5 | // ---- 6 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/address_payable.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | mapping(address => address payable) public m; 3 | function f(address payable arg) public returns (address payable r) { 4 | address payable a = m[arg]; 5 | r = arg; 6 | address c = address(this); 7 | m[c] = payable(0); 8 | } 9 | } 10 | // ---- 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/array_type_name.sol: -------------------------------------------------------------------------------- 1 | contract C { uint[] i; } 2 | 3 | // ---- 4 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/base_constructor_call.sol: -------------------------------------------------------------------------------- 1 | contract A { constructor(uint) {} } 2 | contract C is A { constructor() A(2) {} } 3 | 4 | // ---- 5 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/constructor.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | constructor() { 3 | } 4 | } 5 | // ---- 6 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/contract_dep_order.sol: -------------------------------------------------------------------------------- 1 | contract A { } 2 | contract B is A { } 3 | contract C is B { } 4 | contract D is C { } 5 | contract E is D { } 6 | 7 | // ---- 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/documentation_triple.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | /// test 3 | uint a; 4 | function f() public pure returns (uint x) { 5 | /// test2 6 | for (uint i = 0; i < 20; i++) { 7 | /// tee 8 | /// s "t" 3 9 | x *= 2; 10 | } 11 | /** tes "t4" */ 12 | return x; 13 | } 14 | } 15 | 16 | // ---- 17 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/enum_natspec.sol: -------------------------------------------------------------------------------- 1 | /// @title example of title 2 | /// @author example of author 3 | /// @notice example of notice 4 | /// @dev example of dev 5 | enum Color { 6 | Red, 7 | Green 8 | } 9 | 10 | // ---- 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/enum_value.sol: -------------------------------------------------------------------------------- 1 | contract C { enum E { A, B } } 2 | 3 | // ---- 4 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/enum_value_declaration.sol: -------------------------------------------------------------------------------- 1 | enum A { X, Y } 2 | function f() pure returns (A) { return A.X; } 3 | 4 | // ---- 5 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/event_aggregated_contract.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | event e(); 3 | function f() public { 4 | emit e(); 5 | } 6 | } 7 | contract D { 8 | C c; 9 | constructor() { 10 | c = new C(); 11 | c.f(); 12 | } 13 | } 14 | 15 | // ---- 16 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/event_definition.sol: -------------------------------------------------------------------------------- 1 | contract C { event E(); } 2 | 3 | // ---- 4 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/event_emited_in_base_contract.sol: -------------------------------------------------------------------------------- 1 | library L { event E(uint8); } 2 | contract B { 3 | constructor() { 4 | emit L.E(0); 5 | } 6 | } 7 | contract C is B {} 8 | 9 | // ---- 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/event_emitted_from_foreign_contract.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | event E(address indexed sender); 3 | } 4 | contract D { 5 | function test(address sender) public { 6 | emit C.E(msg.sender); 7 | } 8 | } 9 | 10 | // ---- 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/event_inheritance.sol: -------------------------------------------------------------------------------- 1 | interface B { 2 | event EB(); 3 | } 4 | contract C is B { 5 | event EC(); 6 | } 7 | contract D is C { 8 | event ED(); 9 | } 10 | 11 | // ---- 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/event_with_variables_of_internal_types.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | event E(function() internal); 3 | } 4 | // ---- 5 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/fail_after_parsing.sol: -------------------------------------------------------------------------------- 1 | function g() public; 2 | 3 | interface I { 4 | struct S { S s; } 5 | 6 | function f(E storage e) { 7 | error E; 8 | emit E(); 9 | 10 | ++c; 11 | uint calldata c = 123.4; 12 | } 13 | } 14 | // ---- 15 | // failAfter: Parsed 16 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/fallback.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | fallback() external payable { 3 | } 4 | } 5 | // ---- 6 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/fallback_and_receive_ether.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | receive() external payable { 3 | } 4 | fallback() external payable { 5 | } 6 | } 7 | // ---- 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/fallback_payable.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | fallback() external {} 3 | } 4 | // ---- 5 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/function_type.sol: -------------------------------------------------------------------------------- 1 | contract C { function f(function() external payable returns (uint) x) public returns (function() external view returns (uint)) {} } 2 | 3 | // ---- 4 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/global_enum.sol: -------------------------------------------------------------------------------- 1 | enum E { A } 2 | 3 | // ---- 4 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/global_struct.sol: -------------------------------------------------------------------------------- 1 | struct S { uint256 a; } 2 | 3 | // ---- 4 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/indirect_event.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | library L { 3 | event E(); 4 | function f() internal { emit E(); } 5 | } 6 | contract C { 7 | event H(); 8 | function g() public { L.f(); emit H(); } 9 | } 10 | 11 | // ---- 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/inheritance_specifier.sol: -------------------------------------------------------------------------------- 1 | contract C1 {} contract C2 is C1 {} 2 | 3 | // ---- 4 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/license.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | contract C {} 3 | 4 | // ---- 5 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/long_type_name_binary_operation.sol: -------------------------------------------------------------------------------- 1 | contract c { function f() public { uint a = 2 + 3; } } 2 | 3 | // ---- 4 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/long_type_name_identifier.sol: -------------------------------------------------------------------------------- 1 | contract c { uint[] a; function f() public { uint[] storage b = a; } } 2 | 3 | // ---- 4 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/mappings.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | enum E { A, B, C } 3 | mapping(C => bool) a; 4 | mapping(address => bool) b; 5 | mapping(E => bool) c; 6 | mapping(address keyAddress => uint256 value) d; 7 | } 8 | // ---- 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/modifier_definition.sol: -------------------------------------------------------------------------------- 1 | contract C { modifier M(uint i) { _; } function F() M(1) public {} } 2 | 3 | // ---- 4 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/modifier_invocation.sol: -------------------------------------------------------------------------------- 1 | contract C { modifier M(uint i) { _; } function F() M(1) public {} } 2 | 3 | // ---- 4 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/mutability.sol: -------------------------------------------------------------------------------- 1 | contract C 2 | { 3 | uint public immutable a = 4; 4 | uint public constant b = 2; 5 | uint public c = 3; 6 | } 7 | // ---- 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/non_utf8.sol: -------------------------------------------------------------------------------- 1 | contract C { function f() public { string memory x = string(bytes(hex"ff")); } } 2 | 3 | // ---- 4 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/not_existing_import.sol: -------------------------------------------------------------------------------- 1 | import "notexisting.sol" as NotExisting; 2 | contract C is NotExisting.X 3 | { 4 | NotExisting.SomeStruct public myStruct; 5 | constructor() {} 6 | } 7 | // ---- 8 | // failAfter: Parsed 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/override.sol: -------------------------------------------------------------------------------- 1 | contract A { 2 | function faa() public virtual {} 3 | } 4 | abstract contract B is A { 5 | function foo() public virtual; 6 | function faa() public virtual override {} 7 | } 8 | contract C is B { 9 | function foo() public override { } 10 | function faa() public override { } 11 | } 12 | // ---- 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/placeholder_statement.sol: -------------------------------------------------------------------------------- 1 | contract C { modifier M { _; } } 2 | 3 | // ---- 4 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/pragma_experimental_solidity.sol: -------------------------------------------------------------------------------- 1 | pragma experimental solidity; 2 | // ==== 3 | // EVMVersion: >=constantinople 4 | // ---- 5 | // failAfter: Parsed 6 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/receive_ether.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | receive() external payable { 3 | } 4 | } 5 | // ---- 6 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/short_type_name.sol: -------------------------------------------------------------------------------- 1 | contract c { function f() public { uint[] memory x; } } 2 | 3 | // ---- 4 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/short_type_name_ref.sol: -------------------------------------------------------------------------------- 1 | contract c { function f() public { uint[][] memory rows; } } 2 | 3 | // ---- 4 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/smoke.sol: -------------------------------------------------------------------------------- 1 | contract C {} 2 | 3 | // ---- 4 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/source_location.sol: -------------------------------------------------------------------------------- 1 | contract C { function f() public { uint x = 2; x++; } } 2 | 3 | // ---- 4 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/string.sol: -------------------------------------------------------------------------------- 1 | contract C { function f() public { string memory x = "Hello World"; } } 2 | 3 | // ---- 4 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/struct_natspec.sol: -------------------------------------------------------------------------------- 1 | /// @title example of title 2 | /// @author example of author 3 | /// @notice example of notice 4 | /// @dev example of dev 5 | struct Example { 6 | string text; 7 | bool valid; 8 | uint256 value; 9 | } 10 | 11 | // ---- 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/two_base_functions.sol: -------------------------------------------------------------------------------- 1 | contract A { 2 | function f() public virtual {} 3 | } 4 | contract B { 5 | function f() public virtual {} 6 | } 7 | contract C is A, B { 8 | function f() public override(A, B) {} 9 | } 10 | // ---- 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/unicode.sol: -------------------------------------------------------------------------------- 1 | contract C { function f() public { string memory x = unicode"Hello 😃"; } } 2 | 3 | // ---- 4 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/used_errors.sol: -------------------------------------------------------------------------------- 1 | error X(); 2 | function f() pure { revert X(); } 3 | contract C { 4 | error T(); 5 | function h() public { f(); } 6 | } 7 | // ---- 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/userDefinedValueType.sol: -------------------------------------------------------------------------------- 1 | type MyAddress is address; 2 | type MyUInt is uint; 3 | function f() { 4 | MyAddress a; 5 | MyUInt b; 6 | } 7 | contract C { 8 | type MyAddress is address; 9 | type MyUInt is uint; 10 | mapping(MyAddress => MyUInt) public m; 11 | } 12 | // ---- 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/user_defined_operator.sol: -------------------------------------------------------------------------------- 1 | type I8 is int8; 2 | using {sub as -, unsub as -} for I8 global; 3 | function sub(I8, I8) pure returns (I8) {} 4 | function unsub(I8) pure returns (I8) {} 5 | contract C { 6 | function f(I8 a, I8 b) public pure returns (I8) { 7 | return -a - b; 8 | } 9 | } 10 | // ---- 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/using_for_directive.sol: -------------------------------------------------------------------------------- 1 | using {f} for uint; 2 | library L {} 3 | function f(uint) {} 4 | contract C { using L for *; } 5 | 6 | // ---- 7 | -------------------------------------------------------------------------------- /testcases/libsolidity/ASTJSON/yul_hex_literal.sol: -------------------------------------------------------------------------------- 1 | contract Sample { 2 | function f() public pure { 3 | assembly { 4 | let a := "test" 5 | let b := hex"112233445566778899aabbccddeeff6677889900" 6 | let c := hex"1234_abcd" 7 | } 8 | } 9 | } 10 | // ---- 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/abiEncoderV1/abi_decode_dynamic_array.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(bytes calldata data) external pure returns (uint256[] memory) { 3 | return abi.decode(data, (uint256[])); 4 | } 5 | } 6 | // ---- 7 | // f(bytes): 0x20, 0xc0, 0x20, 0x4, 0x3, 0x4, 0x5, 0x6 -> 0x20, 0x4, 0x3, 0x4, 0x5, 0x6 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/abiEncoderV1/abi_decode_fixed_arrays.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(uint16[3] memory a, uint16[2][3] memory b, uint i, uint j, uint k) 3 | public pure returns (uint, uint) { 4 | return (a[i], b[j][k]); 5 | } 6 | } 7 | // ---- 8 | // f(uint16[3],uint16[2][3],uint256,uint256,uint256): 1, 2, 3, 11, 12, 21, 22, 31, 32, 1, 2, 1 -> 2, 32 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/abiEncoderV1/abi_decode_static_array.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(bytes calldata data) 3 | external 4 | pure 5 | returns (uint256[2][3] memory) 6 | { 7 | return abi.decode(data, (uint256[2][3])); 8 | } 9 | } 10 | // ---- 11 | // f(bytes): 0x20, 0xc0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6 -> 1, 2, 3, 4, 5, 6 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/abiEncoderV1/abi_decode_static_array_v2.sol: -------------------------------------------------------------------------------- 1 | pragma abicoder v2; 2 | 3 | 4 | contract C { 5 | function f(bytes calldata data) 6 | external 7 | pure 8 | returns (uint256[2][3] memory) 9 | { 10 | return abi.decode(data, (uint256[2][3])); 11 | } 12 | } 13 | // ---- 14 | // f(bytes): 0x20, 0xc0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6 -> 1, 2, 3, 4, 5, 6 15 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/abiEncoderV1/abi_decode_trivial.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(bytes memory data) public pure returns (uint256) { 3 | return abi.decode(data, (uint256)); 4 | } 5 | } 6 | // ---- 7 | // f(bytes): 0x20, 0x20, 0x21 -> 33 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/abiEncoderV1/abi_encode_decode_simple.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public pure returns (uint256, bytes memory) { 3 | bytes memory arg = "abcdefg"; 4 | return abi.decode(abi.encode(uint256(33), arg), (uint256, bytes)); 5 | } 6 | } 7 | // ---- 8 | // f() -> 0x21, 0x40, 0x7, "abcdefg" 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/abiEncoderV1/abi_encode_rational.sol: -------------------------------------------------------------------------------- 1 | // Tests that rational numbers (even negative ones) are encoded properly. 2 | contract C { 3 | function f() public pure returns (bytes memory) { 4 | return abi.encode(1, -2); 5 | } 6 | } 7 | // ---- 8 | // f() -> 0x20, 0x40, 0x1, -2 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/abiEncoderV1/bool_out_of_bounds.sol: -------------------------------------------------------------------------------- 1 | pragma abicoder v1; 2 | contract C { 3 | function f(bool b) public pure returns (bool) { return b; } 4 | } 5 | // ==== 6 | // ABIEncoderV1Only: true 7 | // compileViaYul: false 8 | // ---- 9 | // f(bool): true -> true 10 | // f(bool): false -> false 11 | // f(bool): 0x000000 -> false 12 | // f(bool): 0xffffff -> true -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/abiEncoderV1/calldata_arrays_too_large.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(uint a, uint[] calldata b, uint c) external pure returns (uint) { 3 | return 7; 4 | } 5 | } 6 | // ---- 7 | // f(uint256,uint256[],uint256): 6, 0x60, 9, 0x8000000000000000000000000000000000000000000000000000000000000002, 1, 2 -> FAILURE 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/abiEncoderV1/dynamic_arrays.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(uint a, uint16[] memory b, uint c) 3 | public pure returns (uint, uint, uint) { 4 | return (b.length, b[a], c); 5 | } 6 | } 7 | // ---- 8 | // f(uint256,uint16[],uint256): 6, 0x60, 9, 7, 11, 12, 13, 14, 15, 16, 17 -> 7, 17, 9 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/abiEncoderV2/abi_encode_empty_string_v2.sol: -------------------------------------------------------------------------------- 1 | // Tests that this will not end up using a "bytes0" type 2 | // (which would assert) 3 | pragma abicoder v2; 4 | 5 | 6 | contract C { 7 | function f() public pure returns (bytes memory, bytes memory) { 8 | return (abi.encode(""), abi.encodePacked("")); 9 | } 10 | } 11 | // ---- 12 | // f() -> 0x40, 0xa0, 0x40, 0x20, 0x0, 0x0 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/abiEncoderV2/abi_encode_rational_v2.sol: -------------------------------------------------------------------------------- 1 | // Tests that rational numbers (even negative ones) are encoded properly. 2 | pragma abicoder v2; 3 | 4 | 5 | contract C { 6 | function f() public pure returns (bytes memory) { 7 | return abi.encode(1, -2); 8 | } 9 | } 10 | // ---- 11 | // f() -> 0x20, 0x40, 0x1, -2 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/abiEncoderV2/bool_out_of_bounds.sol: -------------------------------------------------------------------------------- 1 | pragma abicoder v2; 2 | 3 | contract C { 4 | function f(bool b) public pure returns (bool) { return b; } 5 | } 6 | // ---- 7 | // f(bool): true -> true 8 | // f(bool): false -> false 9 | // f(bool): 0x000000 -> false 10 | // f(bool): 0xffffff -> FAILURE 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/abiEncoderV2/calldata_array_short_no_revert_string.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(uint[] calldata) public {} 3 | } 4 | // ---- 5 | // f(uint256[]): 0x20, 0 -> 6 | // f(uint256[]): 0x20, 1 -> FAILURE 7 | // f(uint256[]): 0x20, 2 -> FAILURE 8 | 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/abiEncoderV2/dynamic_arrays.sol: -------------------------------------------------------------------------------- 1 | pragma abicoder v2; 2 | 3 | contract C { 4 | function f(uint a, uint16[] memory b, uint c) 5 | public pure returns (uint, uint, uint) { 6 | return (b.length, b[a], c); 7 | } 8 | } 9 | // ---- 10 | // f(uint256,uint16[],uint256): 6, 0x60, 9, 7, 11, 12, 13, 14, 15, 16, 17 -> 7, 17, 9 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/abiEncoderV2/enums.sol: -------------------------------------------------------------------------------- 1 | pragma abicoder v2; 2 | 3 | contract C { 4 | enum E { A, B } 5 | function f(E e) public pure returns (uint x) { 6 | assembly { x := e } 7 | } 8 | } 9 | // ---- 10 | // f(uint8): 0 -> 0 11 | // f(uint8): 1 -> 1 12 | // f(uint8): 2 -> FAILURE 13 | // f(uint8): 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff -> FAILURE 14 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/abiEncoderV2/struct/mediocre_struct.sol: -------------------------------------------------------------------------------- 1 | pragma abicoder v2; 2 | 3 | contract C { 4 | struct S { C c; } 5 | function f(uint a, S[2] memory s1, uint b) public returns (uint r1, C r2, uint r3) { 6 | r1 = a; 7 | r2 = s1[0].c; 8 | r3 = b; 9 | } 10 | } 11 | // ---- 12 | // f(uint256,(address)[2],uint256): 7, 0, 0, 8 -> 7, 0, 8 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/abiencodedecode/abi_decode_calldata.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(bytes calldata data) 3 | external 4 | pure 5 | returns (uint256, bytes memory r) 6 | { 7 | return abi.decode(data, (uint256, bytes)); 8 | } 9 | } 10 | // ---- 11 | // f(bytes): 0x20, 0x80, 0x21, 0x40, 0x7, "abcdefg" -> 0x21, 0x40, 0x7, "abcdefg" 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/abiencodedecode/abi_decode_simple.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(bytes memory data) public pure returns (uint256, bytes memory) { 3 | return abi.decode(data, (uint256, bytes)); 4 | } 5 | } 6 | // ---- 7 | // f(bytes): 0x20, 0x80, 0x21, 0x40, 0x7, "abcdefg" -> 0x21, 0x40, 0x7, "abcdefg" 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/accessor/accessor_for_const_state_variable.sol: -------------------------------------------------------------------------------- 1 | contract Lotto { 2 | uint256 public constant ticketPrice = 555; 3 | } 4 | // ---- 5 | // ticketPrice() -> 555 6 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/accessor/accessor_for_state_variable.sol: -------------------------------------------------------------------------------- 1 | contract Lotto { 2 | uint256 public ticketPrice = 500; 3 | } 4 | // ---- 5 | // ticketPrice() -> 500 6 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/arithmetics/block_inside_unchecked.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public returns (uint y) { 3 | unchecked{{ 4 | uint max = type(uint).max; 5 | uint x = max + 1; 6 | y = x; 7 | }} 8 | } 9 | } 10 | // ---- 11 | // f() -> 0x00 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/arithmetics/checked_add_v2.sol: -------------------------------------------------------------------------------- 1 | pragma abicoder v2; 2 | contract C { 3 | function f(uint16 a, uint16 b) public returns (uint16) { 4 | return a + b; 5 | } 6 | } 7 | // ---- 8 | // f(uint16,uint16): 65534, 0 -> 0xfffe 9 | // f(uint16,uint16): 65536, 0 -> FAILURE 10 | // f(uint16,uint16): 65535, 0 -> 0xffff 11 | // f(uint16,uint16): 65535, 1 -> FAILURE, hex"4e487b71", 0x11 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/array_2d_assignment.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(uint n) public pure returns (uint) { 3 | uint[][] memory a = new uint[][](2); 4 | for (uint i = 0; i < 2; ++i) 5 | a[i] = new uint[](3); 6 | a[1][1] = n; 7 | uint[] memory b = a[1]; 8 | return b[1]; 9 | } 10 | } 11 | // ---- 12 | // f(uint256): 42 -> 42 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/array_2d_new.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(uint n) public pure returns (uint) { 3 | uint[][] memory a = new uint[][](2); 4 | for (uint i = 0; i < 2; ++i) 5 | a[i] = new uint[](3); 6 | return a[0][0] = n; 7 | } 8 | } 9 | // ---- 10 | // f(uint256): 42 -> 42 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/array_3d_new.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(uint n) public pure returns (uint) { 3 | uint[][][] memory a = new uint[][][](2); 4 | for (uint i = 0; i < 2; ++i) 5 | { 6 | a[i] = new uint[][](3); 7 | for (uint j = 0; j < 3; ++j) 8 | a[i][j] = new uint[](4); 9 | } 10 | return a[1][1][1] = n; 11 | } 12 | } 13 | // ---- 14 | // f(uint256): 42 -> 42 15 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/array_memory_create.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function create(uint256 len) public returns (uint256) 3 | { 4 | uint[] memory array = new uint[](len); 5 | return array.length; 6 | } 7 | } 8 | // ---- 9 | // create(uint256): 0 -> 0 10 | // create(uint256): 7 -> 7 11 | // create(uint256): 10 -> 10 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/array_storage_pop_zero_length.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | uint[] storageArray; 3 | function popEmpty() public { 4 | storageArray.pop(); 5 | } 6 | } 7 | // ==== 8 | // EVMVersion: >=petersburg 9 | // ---- 10 | // popEmpty() -> FAILURE, hex"4e487b71", 0x31 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/calldata_array.sol: -------------------------------------------------------------------------------- 1 | pragma abicoder v2; 2 | 3 | 4 | contract C { 5 | function f(uint256[2] calldata s) 6 | external 7 | pure 8 | returns (uint256 a, uint256 b) 9 | { 10 | a = s[0]; 11 | b = s[1]; 12 | } 13 | } 14 | // ---- 15 | // f(uint256[2]): 42, 23 -> 42, 23 16 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/concat/bytes_concat_empty_argument_list.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public returns (bytes memory) { 3 | return bytes.concat(); 4 | } 5 | } 6 | // ---- 7 | // f() -> 0x20, 0 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/concat/bytes_concat_nested.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(bytes memory a, bytes memory b, bytes memory c) public returns (bytes memory) { 3 | return bytes.concat(bytes.concat(a, b), c); 4 | } 5 | } 6 | // ---- 7 | // f(bytes,bytes,bytes): 0x60, 0x60, 0x60, 2, "ab" -> 0x20, 6, "ababab" 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/copying/array_copy_storage_to_memory.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | uint[] a; 3 | function f() public returns (uint, uint) { 4 | a.push(1); a.push(0); a.push(0); 5 | uint[] memory b = a; 6 | return (b[0], b.length); 7 | } 8 | } 9 | // ---- 10 | // f() -> 1, 3 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/copying/bytes_calldata_to_string_calldata.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(bytes calldata c) public returns (string calldata s) { 3 | return string(c); 4 | } 5 | } 6 | // ---- 7 | // f(bytes): 0x20, 3, "abc" -> 0x20, 3, "abc" 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/copying/bytes_memory_to_storage.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | bytes s; 3 | function f() external returns (bytes1) { 4 | bytes memory data = "abcd"; 5 | s = data; 6 | return s[0]; 7 | } 8 | } 9 | // ---- 10 | // f() -> "a" 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/copying/bytes_storage_to_memory.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | bytes s = "abcd"; 3 | function f() external returns (bytes1) { 4 | bytes memory data = s; 5 | return data[0]; 6 | } 7 | } 8 | // ---- 9 | // f() -> "a" 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/copying/calldata_2d_bytes_to_memory.sol: -------------------------------------------------------------------------------- 1 | pragma abicoder v2; 2 | 3 | contract C { 4 | function g(bytes[2] memory m) internal returns (bytes memory) { 5 | return m[0]; 6 | } 7 | function f(bytes[2] calldata c) external returns (bytes memory) { 8 | return g(c); 9 | } 10 | } 11 | // ---- 12 | // f(bytes[2]): 0x20, 0x40, 0x40, 2, "ab" -> 0x20, 2, "ab" 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/copying/calldata_array_static_to_memory.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(uint256[2] calldata c) public returns (uint256, uint256) { 3 | uint256[2] memory m1 = c; 4 | return (m1[0], m1[1]); 5 | } 6 | } 7 | // ---- 8 | // f(uint256[2]): 43, 57 -> 43, 57 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/copying/calldata_bytes_to_storage.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | bytes s; 3 | function f(bytes calldata data) external returns (bytes1) { 4 | s = data; 5 | return s[0]; 6 | } 7 | } 8 | // ---- 9 | // f(bytes): 0x20, 0x08, "abcdefgh" -> "a" 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/copying/calldata_dyn_2d_bytes_to_memory.sol: -------------------------------------------------------------------------------- 1 | pragma abicoder v2; 2 | 3 | contract C { 4 | function f(bytes[] calldata c) external returns (bytes[] memory) { 5 | return c; 6 | } 7 | } 8 | // ---- 9 | // f(bytes[]): 0x20, 2, 0x60, 0x60, 0x20, 2, "ab" -> 0x20, 2, 0x40, 0x80, 2, "ab", 2, "ab" 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/copying/calldata_to_storage_different_base.sol: -------------------------------------------------------------------------------- 1 | pragma abicoder v2; 2 | 3 | contract C { 4 | bytes10[] s; 5 | function f(bytes8[] calldata c) external returns (uint256, bytes10, bytes10, bytes10) { 6 | s = c; 7 | return (s.length, s[0], s[1], s[2]); 8 | } 9 | } 10 | // ---- 11 | // f(bytes8[]): 0x20, 3, "abcd", "bcde", "cdef" -> 3, "abcd", "bcde", "cdef" 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/copying/storage_memory_packed.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | uint8[33] a; 3 | 4 | function f() public returns (uint8, uint8, uint8) { 5 | a[0] = 2; 6 | a[16] = 3; 7 | a[32] = 4; 8 | uint8[33] memory m = a; 9 | return (m[0], m[16], m[32]); 10 | } 11 | } 12 | // ---- 13 | // f() -> 2, 3, 4 14 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/copying/string_calldata_to_bytes_calldata.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(string calldata s) public returns (bytes calldata m) { 3 | return bytes(s); 4 | } 5 | } 6 | // ---- 7 | // f(string): 0x20, 3, "abc" -> 0x20, 3, "abc" 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/create_dynamic_array_with_zero_length.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public returns (uint256) { 3 | uint256[][] memory a = new uint256[][](0); 4 | return 7; 5 | } 6 | } 7 | // ---- 8 | // f() -> 7 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/create_memory_byte_array.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public returns (bytes1) { 3 | bytes memory x = new bytes(35); 4 | assert(x.length == 35); 5 | x[34] = "A"; 6 | return (x[34]); 7 | } 8 | } 9 | // ---- 10 | // f() -> "A" 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/delete/delete_memory_array.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | 3 | function len() public returns (uint ret) { 4 | uint[] memory data = new uint[](2); 5 | data[0] = 234; 6 | data[1] = 123; 7 | delete data; 8 | assembly { 9 | ret := mload(data) 10 | } 11 | } 12 | } 13 | // ---- 14 | // len() -> 0 15 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/delete/delete_removes_bytes_data.sol: -------------------------------------------------------------------------------- 1 | contract c { 2 | fallback() external { data = msg.data; } 3 | function del() public returns (bool) { delete data; return true; } 4 | bytes data; 5 | } 6 | // ---- 7 | // (): 7 -> 8 | // storageEmpty -> 0 9 | // del(): 7 -> true 10 | // storageEmpty -> 1 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/fixed_bytes_length_access.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | bytes1 a; 3 | 4 | function f(bytes32 x) public returns (uint256, uint256, uint256) { 5 | return (x.length, bytes16(uint128(2)).length, a.length + 7); 6 | } 7 | } 8 | // ---- 9 | // f(bytes32): "789" -> 32, 16, 8 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/indexAccess/bytes_memory_index_access.sol: -------------------------------------------------------------------------------- 1 | contract Test { 2 | function set(bytes memory _data, uint256 i) 3 | public 4 | returns (uint256 l, bytes1 c) 5 | { 6 | l = _data.length; 7 | c = _data[i]; 8 | } 9 | } 10 | // ---- 11 | // set(bytes,uint256): 0x40, 0x03, 0x08, "abcdefgh" -> 0x08, "d" 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/indexAccess/inline_array_index_access_ints.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public returns (uint256) { 3 | return ([1, 2, 3, 4][2]); 4 | } 5 | } 6 | // ---- 7 | // f() -> 3 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/indexAccess/inline_array_index_access_strings.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | string public tester; 3 | 4 | function f() public returns (string memory) { 5 | return (["abc", "def", "g"][0]); 6 | } 7 | 8 | function test() public { 9 | tester = f(); 10 | } 11 | } 12 | // ---- 13 | // test() -> 14 | // tester() -> 0x20, 0x3, "abc" 15 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/inline_array_singleton.sol: -------------------------------------------------------------------------------- 1 | // This caused a failure since the type was not converted to its mobile type. 2 | contract C { 3 | function f() public returns (uint256) { 4 | return [4][0]; 5 | } 6 | } 7 | // ---- 8 | // f() -> 4 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/inline_array_storage_to_memory_conversion_ints.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public returns (uint256 x, uint256 y) { 3 | x = 3; 4 | y = 6; 5 | uint256[2] memory z = [x, y]; 6 | return (z[0], z[1]); 7 | } 8 | } 9 | // ---- 10 | // f() -> 3, 6 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/inline_array_storage_to_memory_conversion_strings.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | string s = "doh"; 3 | 4 | function f() public returns (string memory, string memory) { 5 | string memory t = "ray"; 6 | string[3] memory x = [s, t, "mi"]; 7 | return (x[1], x[2]); 8 | } 9 | } 10 | // ---- 11 | // f() -> 0x40, 0x80, 0x3, "ray", 0x2, "mi" 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/pop/array_pop.sol: -------------------------------------------------------------------------------- 1 | contract c { 2 | uint256[] data; 3 | 4 | function test() public returns (uint256 x, uint256 l) { 5 | data.push(7); 6 | data.push(3); 7 | x = data.length; 8 | data.pop(); 9 | x = data.length; 10 | data.pop(); 11 | l = data.length; 12 | } 13 | } 14 | // ---- 15 | // test() -> 1, 0 16 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/pop/array_pop_empty_exception.sol: -------------------------------------------------------------------------------- 1 | contract c { 2 | uint256[] data; 3 | 4 | function test() public returns (bool) { 5 | data.pop(); 6 | return true; 7 | } 8 | } 9 | // ---- 10 | // test() -> FAILURE, hex"4e487b71", 0x31 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/pop/array_pop_isolated.sol: -------------------------------------------------------------------------------- 1 | // This tests that the compiler knows the correct size of the function on the stack. 2 | contract c { 3 | uint256[] data; 4 | 5 | function test() public returns (uint256 x) { 6 | x = 2; 7 | data.pop; 8 | x = 3; 9 | } 10 | } 11 | // ---- 12 | // test() -> 3 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/pop/array_pop_storage_empty.sol: -------------------------------------------------------------------------------- 1 | contract c { 2 | uint[] data; 3 | function test() public { 4 | data.push(7); 5 | data.pop(); 6 | } 7 | } 8 | // ---- 9 | // test() -> 10 | // storageEmpty -> 1 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/pop/byte_array_pop_empty_exception.sol: -------------------------------------------------------------------------------- 1 | contract c { 2 | uint256 a; 3 | uint256 b; 4 | uint256 c; 5 | bytes data; 6 | 7 | function test() public returns (bool) { 8 | data.pop(); 9 | return true; 10 | } 11 | } 12 | // ---- 13 | // test() -> FAILURE, hex"4e487b71", 0x31 14 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/pop/byte_array_pop_isolated.sol: -------------------------------------------------------------------------------- 1 | // This tests that the compiler knows the correct size of the function on the stack. 2 | contract c { 3 | bytes data; 4 | 5 | function test() public returns (uint256 x) { 6 | x = 2; 7 | data.pop; 8 | x = 3; 9 | } 10 | } 11 | // ---- 12 | // test() -> 3 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/pop/byte_array_pop_storage_empty.sol: -------------------------------------------------------------------------------- 1 | contract c { 2 | bytes data; 3 | function test() public { 4 | data.push(0x07); 5 | data.push(0x05); 6 | data.push(0x03); 7 | data.pop(); 8 | data.pop(); 9 | data.pop(); 10 | } 11 | } 12 | // ---- 13 | // test() -> 14 | // storageEmpty -> 1 15 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/pop/parenthesized.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | int[] data; 3 | function f() public returns (uint) { 4 | data.push(1); 5 | (data.pop)(); 6 | return data.length; 7 | } 8 | } 9 | // ---- 10 | // f() -> 0 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/push/array_push_nested.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | uint8 b = 23; 3 | uint120[][] s; 4 | uint8 a = 17; 5 | function f() public { 6 | s.push(); 7 | assert(s.length == 1); 8 | assert(s[0].length == 0); 9 | s[0].push(); 10 | assert(s[0].length == 1); 11 | assert(s[0][0] == 0); 12 | } 13 | } 14 | // ---- 15 | // f() -> 16 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/array/slices/array_calldata_assignment.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(uint256[] calldata x, uint256[] calldata y, uint256 i) external returns (uint256) { 3 | x = y; 4 | return x[i]; 5 | } 6 | } 7 | // ---- 8 | // f(uint256[],uint256[],uint256): 0x60, 0xA0, 1, 1, 0, 2, 1, 2 -> 2 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/asmForLoop/for_loop_break.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public returns (uint i) { 3 | assembly { 4 | for {} lt(i, 10) { i := add(i, 1) } 5 | { 6 | if eq(i, 6) { break } 7 | i := add(i, 1) 8 | } 9 | } 10 | } 11 | } 12 | // ---- 13 | // f() -> 6 14 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/asmForLoop/for_loop_continue.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public returns (uint k) { 3 | assembly { 4 | for {let i := 0} lt(i, 10) { i := add(i, 1) } 5 | { 6 | if eq(mod(i, 2), 0) { continue } 7 | k := add(k, 1) 8 | } 9 | } 10 | } 11 | } 12 | // ---- 13 | // f() -> 5 14 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/builtinFunctions/assignment_to_const_var_involving_keccak.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | bytes32 constant x = keccak256("abc"); 3 | 4 | function f() public returns (bytes32) { 5 | return x; 6 | } 7 | } 8 | // ---- 9 | // f() -> 0x4e03657aea45a94fc7d47ba826c8d667c0d1e6e33a64a036ec44f58fa12d6c45 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/builtinFunctions/blobhash_shadow_resolution.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function blobhash(uint256 index) public pure returns(bytes32) { 3 | return bytes32(index); 4 | } 5 | function f() public pure returns(bytes32) { 6 | return blobhash(3); 7 | } 8 | } 9 | // ==== 10 | // EVMVersion: >=cancun 11 | // ---- 12 | // f() -> 0x03 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/builtinFunctions/blockhash_shadow_resolution.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function blockhash(uint256 blockNumber) public returns(bytes32) { bytes32 x; return x; } 3 | function f() public returns(bytes32) { return blockhash(3); } 4 | } 5 | // ---- 6 | // f() -> 0 7 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/builtinFunctions/keccak256_empty.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public returns (bytes32) { 3 | return keccak256(""); 4 | } 5 | } 6 | // ---- 7 | // f() -> 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/builtinFunctions/keccak256_multiple_arguments.sol: -------------------------------------------------------------------------------- 1 | contract c { 2 | function foo(uint256 a, uint256 b, uint256 c) public returns (bytes32 d) { 3 | d = keccak256(abi.encodePacked(a, b, c)); 4 | } 5 | } 6 | // ---- 7 | // foo(uint256,uint256,uint256): 0xa, 0xc, 0xd -> 0xbc740a98aae5923e8f04c9aa798c9ee82f69e319997699f2782c40828db9fd81 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/builtinFunctions/keccak256_multiple_arguments_with_numeric_literals.sol: -------------------------------------------------------------------------------- 1 | contract c { 2 | function foo(uint256 a, uint16 b) public returns (bytes32 d) { 3 | d = keccak256(abi.encodePacked(a, b, uint8(145))); 4 | } 5 | } 6 | // ---- 7 | // foo(uint256,uint16): 0xa, 0xc -> 0x88acd45f75907e7c560318bc1a5249850a0999c4896717b1167d05d116e6dbad 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/builtinFunctions/keccak256_with_bytes.sol: -------------------------------------------------------------------------------- 1 | contract c { 2 | bytes data; 3 | 4 | function foo() public returns (bool) { 5 | data.push("f"); 6 | data.push("o"); 7 | data.push("o"); 8 | return keccak256(data) == keccak256("foo"); 9 | } 10 | } 11 | // ---- 12 | // foo() -> true 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/builtinFunctions/msg_sig.sol: -------------------------------------------------------------------------------- 1 | contract test { 2 | function foo(uint256 a) public returns (bytes4 value) { 3 | return msg.sig; 4 | } 5 | } 6 | // ---- 7 | // foo(uint256): 0x0 -> 0x2fbebd3800000000000000000000000000000000000000000000000000000000 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/builtinFunctions/msg_sig_after_internal_call_is_same.sol: -------------------------------------------------------------------------------- 1 | contract test { 2 | function boo() public returns (bytes4 value) { 3 | return msg.sig; 4 | } 5 | 6 | function foo(uint256 a) public returns (bytes4 value) { 7 | return boo(); 8 | } 9 | } 10 | // ---- 11 | // foo(uint256): 0x0 -> 0x2fbebd3800000000000000000000000000000000000000000000000000000000 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/builtinFunctions/ripemd160_empty.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public returns (bytes20) { 3 | return ripemd160(""); 4 | } 5 | } 6 | // ---- 7 | // f() -> 0x9c1185a5c5e9fc54612808977ee8f548b2258d31000000000000000000000000 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/builtinFunctions/sha256_empty.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public returns (bytes32) { 3 | return sha256(""); 4 | } 5 | } 6 | // ---- 7 | // f() -> 0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/calldata/calldata_bytes_external.sol: -------------------------------------------------------------------------------- 1 | contract CalldataTest { 2 | function test(bytes calldata x) public returns (bytes calldata) { 3 | return x; 4 | } 5 | function tester(bytes calldata x) public returns (bytes1) { 6 | return this.test(x)[2]; 7 | } 8 | } 9 | // ==== 10 | // EVMVersion: >=byzantium 11 | // ---- 12 | // tester(bytes): 0x20, 0x08, "abcdefgh" -> "c" 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/calldata/calldata_bytes_internal.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(bytes calldata b, uint i) internal pure returns (bytes1) { 3 | return b[i]; 4 | } 5 | function f(uint, bytes calldata b, uint) external pure returns (bytes1) { 6 | return f(b, 2); 7 | } 8 | } 9 | // ---- 10 | // f(uint256,bytes,uint256): 7, 0x60, 7, 4, "abcd" -> "c" 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/calldata/calldata_bytes_to_memory.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(bytes calldata data) external returns (bytes32) { 3 | return keccak256(bytes(data)); 4 | } 5 | } 6 | // ---- 7 | // f(bytes): 0x20, 0x08, "abcdefgh" -> 0x48624fa43c68d5c552855a4e2919e74645f683f5384f72b5b051b71ea41d4f2d 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/calldata/calldata_bytes_to_memory_encode.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(bytes calldata data) external returns (bytes memory) { 3 | return abi.encode(bytes(data)); 4 | } 5 | } 6 | // ---- 7 | // f(bytes): 0x20, 0x08, "abcdefgh" -> 0x20, 0x60, 0x20, 8, 44048183304486788309563647967830685498285570828042699209880294173606615711744 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/cleanup/cleanup_in_compound_assign.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function test() public returns (uint256, uint256) { 3 | uint32 a = 0xffffffff; 4 | uint16 x = uint16(a); 5 | uint16 y = x; 6 | x /= 0x100; 7 | y = y / 0x100; 8 | return (x, y); 9 | } 10 | } 11 | // ---- 12 | // test() -> 0xff, 0xff 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/cleanup/exp_cleanup.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public pure returns (uint x) { 3 | unchecked { 4 | uint8 y = uint8(2)**uint8(8); 5 | return 0**y; 6 | } 7 | } 8 | } 9 | // ---- 10 | // f() -> 0x1 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/cleanup/exp_cleanup_direct.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public pure returns (uint8 x) { 3 | unchecked { 4 | return uint8(0)**uint8(uint8(2)**uint8(8)); 5 | } 6 | } 7 | } 8 | // ---- 9 | // f() -> 0x1 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/cleanup/exp_cleanup_nonzero_base.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public pure returns (uint8 x) { 3 | unchecked { 4 | uint16 x = 0x166; 5 | return uint8(x)**uint8(uint8(2)**uint8(8)); 6 | } 7 | } 8 | } 9 | // ---- 10 | // f() -> 0x1 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/cleanup/exp_cleanup_smaller_base.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public pure returns (uint16 x) { 3 | // tests that ``e`` is not converted to uint8 4 | // right before the exp 5 | uint16 e = 0x100; 6 | uint8 b = 0x2; 7 | unchecked { 8 | return b**e; 9 | } 10 | } 11 | } 12 | // ---- 13 | // f() -> 0x00 14 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/constantEvaluator/negative_fractional_mod.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public pure returns (int, int) { 3 | int x = int((-(-5.2 % 3)) * 5); 4 | int t = 5; 5 | return (x, (-(-t % 3)) * 5); 6 | } 7 | } 8 | // ---- 9 | // f() -> 11, 10 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/constantEvaluator/rounding.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | int constant a = 7; 3 | int constant b = 3; 4 | int constant c = a / b; 5 | int constant d = (-a) / b; 6 | function f() public pure returns (uint, int, uint, int) { 7 | uint[c] memory x; 8 | uint[-d] memory y; 9 | return (x.length, c, y.length, -d); 10 | } 11 | } 12 | // ---- 13 | // f() -> 2, 2, 2, 2 14 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/constants/asm_address_constant_regression.sol: -------------------------------------------------------------------------------- 1 | // Test for regression of https://github.com/ethereum/solidity/issues/8406 2 | 3 | contract C { 4 | address constant e = 0x1212121212121212121212121000002134593163; 5 | 6 | function f() public returns (bytes1 z) { 7 | assembly { z := e } 8 | } 9 | } 10 | // ---- 11 | // f() -> 0x00 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/constants/asm_constant_file_level.sol: -------------------------------------------------------------------------------- 1 | address constant e = 0x1212121212121212121212121000002134593163; 2 | 3 | contract C { 4 | function f() public returns (address z) { 5 | assembly { z := e } 6 | } 7 | } 8 | // ---- 9 | // f() -> 0x1212121212121212121212121000002134593163 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/constants/constant_variables.sol: -------------------------------------------------------------------------------- 1 | contract Foo { 2 | uint256 constant x = 56; 3 | enum ActionChoices {GoLeft, GoRight, GoStraight, Sit} 4 | ActionChoices constant choices = ActionChoices.GoLeft; 5 | bytes32 constant st = "abc\x00\xff__"; 6 | } 7 | // ---- 8 | // constructor() -> 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/constants/consteval_array_length.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | uint constant a = 12; 3 | uint constant b = 10; 4 | 5 | function f() public pure returns (uint, uint) { 6 | uint[(a / b) * b] memory x; 7 | return (x.length, (a / b) * b); 8 | } 9 | } 10 | // ==== 11 | // compileViaYul: true 12 | // ---- 13 | // constructor() -> 14 | // f() -> 0x0a, 0x0a 15 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/constants/function_unreferenced.sol: -------------------------------------------------------------------------------- 1 | contract B { 2 | function g() public {} 3 | } 4 | contract C is B { 5 | bytes4 constant s2 = B.g.selector; 6 | function f() external pure returns (bytes4) { return s2; } 7 | } 8 | // ---- 9 | // f() -> 0xe2179b8e00000000000000000000000000000000000000000000000000000000 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/constants/simple_constant_variables_test.sol: -------------------------------------------------------------------------------- 1 | contract Foo { 2 | function getX() public returns (uint256 r) { 3 | return x; 4 | } 5 | 6 | uint256 constant x = 56; 7 | } 8 | // ---- 9 | // getX() -> 56 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/constructor/constructor_function_argument.sol: -------------------------------------------------------------------------------- 1 | // The IR of this test used to throw 2 | contract D { 3 | constructor(function() external returns (uint)) { 4 | } 5 | } 6 | // ---- 7 | // constructor(): 0xfdd67305928fcac8d213d1e47bfa6165cd0b87b946644cd0000000000000000 -> 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/constructor/evm_exceptions_in_constructor_call_fail.sol: -------------------------------------------------------------------------------- 1 | contract A { 2 | constructor() { 3 | address(this).call("123"); 4 | } 5 | } 6 | 7 | 8 | contract B { 9 | uint256 public test = 1; 10 | 11 | function testIt() public { 12 | A a = new A(); 13 | ++test; 14 | } 15 | } 16 | // ---- 17 | // testIt() -> 18 | // test() -> 2 19 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/constructor/payable_constructor.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | constructor() payable {} 3 | } 4 | // ---- 5 | // constructor(), 27 wei -> 6 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/constructor_inheritance_init_order.sol: -------------------------------------------------------------------------------- 1 | contract A { 2 | uint x; 3 | constructor() { 4 | x = 42; 5 | } 6 | function f() public returns(uint256) { 7 | return x; 8 | } 9 | } 10 | contract B is A { 11 | uint public y = f(); 12 | } 13 | // ==== 14 | // compileViaYul: true 15 | // ---- 16 | // constructor() -> 17 | // gas irOptimized: 119640 18 | // y() -> 42 19 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/constructor_inheritance_init_order_2.sol: -------------------------------------------------------------------------------- 1 | contract A { 2 | uint x = 42; 3 | function f() public returns(uint256) { 4 | return x; 5 | } 6 | } 7 | contract B is A { 8 | uint public y = f(); 9 | } 10 | // ---- 11 | // constructor() -> 12 | // gas irOptimized: 119640 13 | // gas legacy: 133594 14 | // gas legacyOptimized: 115341 15 | // y() -> 42 16 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/constructor_inheritance_init_order_3_legacy.sol: -------------------------------------------------------------------------------- 1 | contract A { 2 | uint public x = 2; 3 | constructor(uint) {} 4 | function f() public returns(uint) { x = 4; } 5 | } 6 | contract B is A { 7 | constructor() A(f()) {} 8 | } 9 | // ==== 10 | // compileViaYul: false 11 | // ---- 12 | // x() -> 4 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/constructor_inheritance_init_order_3_viaIR.sol: -------------------------------------------------------------------------------- 1 | contract A { 2 | uint public x = 2; 3 | constructor(uint) {} 4 | function f() public returns(uint) { x = 4; } 5 | } 6 | contract B is A { 7 | constructor() A(f()) {} 8 | } 9 | // ==== 10 | // compileViaYul: true 11 | // ---- 12 | // x() -> 2 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/constructor_with_params.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | uint public i; 3 | uint public k; 4 | 5 | constructor(uint newI, uint newK) { 6 | i = newI; 7 | k = newK; 8 | } 9 | } 10 | // ---- 11 | // constructor(): 2, 0 -> 12 | // gas irOptimized: 101390 13 | // gas legacy: 115678 14 | // i() -> 2 15 | // k() -> 0 16 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/constructor_with_params_inheritance_2.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | uint public i; 3 | uint public k; 4 | 5 | constructor(uint newI, uint newK) { 6 | i = newI; 7 | k = newK; 8 | } 9 | } 10 | contract D is C(2, 1) {} 11 | // ---- 12 | // i() -> 2 13 | // k() -> 1 14 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/conversions/string_to_bytes.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(string memory s) public pure returns (bytes memory t) { 3 | t = bytes(s); 4 | } 5 | } 6 | // ---- 7 | // f(string): 32, 5, "Hello" -> 32, 5, "Hello" 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/dirty_calldata_bytes.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(bytes calldata b) public returns (bool correct) { 3 | bytes1 a = b[3]; 4 | uint r; 5 | assembly { 6 | r := a 7 | } 8 | correct = r == (0x64 << 248); 9 | } 10 | } 11 | // ---- 12 | // f(bytes): 0x20, 0x04, "dead" -> true 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/dirty_calldata_dynamic_array.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(int16[] calldata a) external returns (bool correct) { 3 | uint32 x = uint32(uint16(a[1])); 4 | uint r; 5 | assembly { 6 | r := x 7 | } 8 | correct = r == 0x7fff; 9 | } 10 | } 11 | // ---- 12 | // f(int16[]): 0x20, 0x02, 0x7fff, 0x7fff -> true 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/emit_three_identical_events.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | event Terminated(); 3 | 4 | function terminate() external { 5 | emit Terminated(); 6 | emit Terminated(); 7 | emit Terminated(); 8 | } 9 | } 10 | // ---- 11 | // terminate() -> 12 | // ~ emit Terminated() 13 | // ~ emit Terminated() 14 | // ~ emit Terminated() -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/emit_two_identical_events.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | event Terminated(); 3 | 4 | function terminate() external { 5 | emit Terminated(); 6 | emit Terminated(); 7 | } 8 | } 9 | // ---- 10 | // terminate() -> 11 | // ~ emit Terminated() 12 | // ~ emit Terminated() -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/empty_contract.sol: -------------------------------------------------------------------------------- 1 | contract test { 2 | } 3 | // ==== 4 | // allowNonExistingFunctions: true 5 | // ---- 6 | // i_am_not_there() -> FAILURE 7 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/empty_for_loop.sol: -------------------------------------------------------------------------------- 1 | contract test { 2 | function f() public returns(uint ret) { 3 | ret = 1; 4 | for (;;) { 5 | ret += 1; 6 | if (ret >= 10) break; 7 | } 8 | } 9 | } 10 | // ---- 11 | // f() -> 10 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/enums/constructing_enums_from_ints.sol: -------------------------------------------------------------------------------- 1 | contract c { 2 | enum Truth {False, True} 3 | 4 | function test() public returns (uint256) { 5 | return uint256(Truth(uint8(0x1))); 6 | } 7 | } 8 | // ---- 9 | // test() -> 1 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/enums/minmax.sol: -------------------------------------------------------------------------------- 1 | contract test { 2 | enum MinMax { A, B, C, D } 3 | 4 | function min() public returns(uint) { return uint(type(MinMax).min); } 5 | function max() public returns(uint) { return uint(type(MinMax).max); } 6 | } 7 | // ---- 8 | // min() -> 0 9 | // max() -> 3 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/enums/using_contract_enums_with_explicit_contract_name.sol: -------------------------------------------------------------------------------- 1 | contract test { 2 | enum Choice {A, B, C} 3 | 4 | function answer() public returns (test.Choice _ret) { 5 | _ret = test.Choice.B; 6 | } 7 | } 8 | // ---- 9 | // answer() -> 1 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/enums/using_enums.sol: -------------------------------------------------------------------------------- 1 | contract test { 2 | enum ActionChoices {GoLeft, GoRight, GoStraight, Sit} 3 | 4 | constructor() { 5 | choices = ActionChoices.GoStraight; 6 | } 7 | 8 | function getChoice() public returns (uint256 d) { 9 | d = uint256(choices); 10 | } 11 | 12 | ActionChoices choices; 13 | } 14 | // ---- 15 | // getChoice() -> 2 16 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/enums/using_inherited_enum.sol: -------------------------------------------------------------------------------- 1 | contract base { 2 | enum Choice {A, B, C} 3 | } 4 | 5 | 6 | contract test is base { 7 | function answer() public returns (Choice _ret) { 8 | _ret = Choice.B; 9 | } 10 | } 11 | // ---- 12 | // answer() -> 1 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/enums/using_inherited_enum_excplicitly.sol: -------------------------------------------------------------------------------- 1 | contract base { 2 | enum Choice {A, B, C} 3 | } 4 | 5 | 6 | contract test is base { 7 | function answer() public returns (base.Choice _ret) { 8 | _ret = base.Choice.B; 9 | } 10 | } 11 | // ---- 12 | // answer() -> 1 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/errors/named_error_args.sol: -------------------------------------------------------------------------------- 1 | error E(uint a, uint b); 2 | contract C { 3 | function f() public pure { 4 | revert E({b: 7, a: 2}); 5 | } 6 | } 7 | // ---- 8 | // f() -> FAILURE, hex"85208890", hex"0000000000000000000000000000000000000000000000000000000000000002", hex"0000000000000000000000000000000000000000000000000000000000000007" 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/errors/revert_conversion.sol: -------------------------------------------------------------------------------- 1 | error E(string a, uint[] b); 2 | contract C { 3 | uint[] x; 4 | function f() public { 5 | x.push(7); 6 | revert E("abc", x); 7 | } 8 | } 9 | // ---- 10 | // f() -> FAILURE, hex"59e4d4df", 0x40, 0x80, 3, "abc", 1, 7 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/errors/simple.sol: -------------------------------------------------------------------------------- 1 | error E(uint a, uint b); 2 | contract C { 3 | function f() public pure { 4 | revert E(2, 7); 5 | } 6 | } 7 | // ---- 8 | // f() -> FAILURE, hex"85208890", 2, 7 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/errors/weird_name.sol: -------------------------------------------------------------------------------- 1 | error error(uint a); 2 | contract C { 3 | function f() public pure { 4 | revert error(2); 5 | } 6 | } 7 | // ---- 8 | // f() -> FAILURE, hex"b48fb6cf", hex"0000000000000000000000000000000000000000000000000000000000000002" 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/events/event_access_through_base_name_emit.sol: -------------------------------------------------------------------------------- 1 | contract A { 2 | event x(); 3 | } 4 | contract B is A { 5 | function f() public returns (uint) { 6 | emit A.x(); 7 | return 1; 8 | } 9 | } 10 | // ---- 11 | // f() -> 1 12 | // ~ emit x() 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/events/event_anonymous.sol: -------------------------------------------------------------------------------- 1 | contract ClientReceipt { 2 | event Deposit() anonymous; 3 | function deposit() public { 4 | emit Deposit(); 5 | } 6 | } 7 | // ---- 8 | // deposit() -> 9 | // ~ emit 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/events/event_constructor.sol: -------------------------------------------------------------------------------- 1 | contract ClientReceipt { 2 | event Deposit(address indexed _from, bytes32 indexed _id, uint _value); 3 | constructor() { 4 | emit Deposit(msg.sender, bytes32("abc"), 7); 5 | } 6 | } 7 | // ---- 8 | // constructor() 9 | // ~ emit Deposit(address,bytes32,uint256): #0x1212121212121212121212121212120000000012, #"abc", 0x07 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/events/event_dynamic_array_memory.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | event E(uint[]); 3 | function createEvent(uint x) public { 4 | uint[] memory arr = new uint[](3); 5 | arr[0] = x; 6 | arr[1] = x + 1; 7 | arr[2] = x + 2; 8 | emit E(arr); 9 | } 10 | } 11 | // ---- 12 | // createEvent(uint256): 42 -> 13 | // ~ emit E(uint256[]): 0x20, 0x03, 0x2a, 0x2b, 0x2c 14 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/events/event_emit_from_a_foreign_contract.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | event E(); 3 | } 4 | 5 | contract D { 6 | function test() public { 7 | emit C.E(); 8 | } 9 | } 10 | 11 | // ---- 12 | // test() -> 13 | // ~ emit E() 14 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/events/event_emit_from_a_foreign_contract_same_name.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | event E(uint256 value); 3 | } 4 | 5 | contract D { 6 | event E(uint256 value); 7 | 8 | function test() public { 9 | emit C.E(1); 10 | emit E(2); 11 | } 12 | } 13 | 14 | // ---- 15 | // test() -> 16 | // ~ emit E(uint256): 0x01 17 | // ~ emit E(uint256): 0x02 18 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/events/event_emit_interface_event_via_library.sol: -------------------------------------------------------------------------------- 1 | interface I { 2 | event E(); 3 | } 4 | 5 | library L { 6 | function f() internal { 7 | emit I.E(); 8 | } 9 | } 10 | 11 | contract C { 12 | function g() public { 13 | L.f(); 14 | } 15 | } 16 | 17 | // ---- 18 | // g() -> 19 | // ~ emit E() 20 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/events/event_emit_via_interface.sol: -------------------------------------------------------------------------------- 1 | interface I { 2 | event Event(address indexed _from, uint256 _value); 3 | } 4 | 5 | contract C { 6 | function emitEvent(uint256 _value) public { 7 | emit I.Event(msg.sender, _value); 8 | } 9 | } 10 | 11 | // ---- 12 | // emitEvent(uint256): 100 -> 13 | // ~ emit Event(address,uint256): #0x1212121212121212121212121212120000000012, 0x64 14 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/events/event_indexed_function.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | event Test(function() external indexed); 3 | function f() public { 4 | emit Test(this.f); 5 | } 6 | } 7 | // ---- 8 | // f() -> 9 | // ~ emit Test(function): #0xc06afe3a8444fc0004668591e8306bfb9968e79e26121ff00000000000000000 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/events/event_no_arguments.sol: -------------------------------------------------------------------------------- 1 | contract ClientReceipt { 2 | event Deposit(); 3 | function deposit() public { 4 | emit Deposit(); 5 | } 6 | } 7 | // ---- 8 | // deposit() -> 9 | // ~ emit Deposit() 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/events/event_really_lots_of_data.sol: -------------------------------------------------------------------------------- 1 | contract ClientReceipt { 2 | event Deposit(uint fixeda, bytes dynx, uint fixedb); 3 | function deposit() public { 4 | emit Deposit(10, msg.data, 15); 5 | } 6 | } 7 | // ---- 8 | // deposit() -> 9 | // ~ emit Deposit(uint256,bytes,uint256): 0x0a, 0x60, 0x0f, 0x04, 0xd0e30db000000000000000000000000000000000000000000000000000000000 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/events/event_string.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | event E(string r); 3 | function deposit() public { 4 | emit E("HELLO WORLD"); 5 | } 6 | } 7 | // ---- 8 | // deposit() -> 9 | // ~ emit E(string): 0x20, 0x0b, "HELLO WORLD" 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/events/event_struct_memory_v2.sol: -------------------------------------------------------------------------------- 1 | pragma abicoder v2; 2 | contract C { 3 | struct S { uint a; } 4 | event E(S); 5 | function createEvent(uint x) public { 6 | emit E(S(x)); 7 | } 8 | } 9 | // ---- 10 | // createEvent(uint256): 42 -> 11 | // ~ emit E((uint256)): 0x2a 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/events/event_struct_storage_v2.sol: -------------------------------------------------------------------------------- 1 | pragma abicoder v2; 2 | contract C { 3 | struct S { uint a; } 4 | event E(S); 5 | S s; 6 | function createEvent(uint x) public { 7 | s.a = x; 8 | emit E(s); 9 | } 10 | } 11 | // ---- 12 | // createEvent(uint256): 42 -> 13 | // ~ emit E((uint256)): 0x2a 14 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/events/simple.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | event E(); 3 | } 4 | 5 | contract Test is C { 6 | event E(uint256, uint256); 7 | function f() public { 8 | emit C.E(); 9 | emit E(1,2); 10 | } 11 | } 12 | // ==== 13 | // compileViaYul: also 14 | // ---- 15 | // f() -> 16 | // ~ emit E() 17 | // ~ emit E(uint256,uint256): 0x01, 0x02 18 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/exponentiation/signed_base.sol: -------------------------------------------------------------------------------- 1 | contract test { 2 | function f() public pure returns (int, int) { 3 | int32 x = -3; 4 | uint8 y1; 5 | uint8 y2; 6 | assembly { 7 | y1 := 0x102 8 | y2 := 0x103 9 | } 10 | return (x**y1, x**y2); 11 | } 12 | } 13 | // ---- 14 | // f() -> 9, -27 15 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/exponentiation/small_exp.sol: -------------------------------------------------------------------------------- 1 | contract test { 2 | function f() public pure returns (uint r) { 3 | uint32 x; 4 | uint8 y; 5 | assembly { 6 | x := 0xfffffffffe 7 | y := 0x102 8 | } 9 | unchecked { r = x**y; } 10 | return r; 11 | } 12 | } 13 | // ---- 14 | // f() -> 4 15 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/expressions/bytes_comparison.sol: -------------------------------------------------------------------------------- 1 | contract test { 2 | function f() public returns (bool) { 3 | bytes2 a = "a"; 4 | bytes2 x = "aa"; 5 | bytes2 b = "b"; 6 | return a < x && x < b; 7 | } 8 | } 9 | // ---- 10 | // f() -> true 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/expressions/conditional_expression_different_types.sol: -------------------------------------------------------------------------------- 1 | contract test { 2 | function f(bool cond) public returns (uint) { 3 | uint8 x = 0xcd; 4 | uint16 y = 0xabab; 5 | return cond ? x : y; 6 | } 7 | } 8 | // ---- 9 | // f(bool): true -> 0xcd 10 | // f(bool): false -> 0xabab 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/expressions/conditional_expression_false_literal.sol: -------------------------------------------------------------------------------- 1 | contract test { 2 | function f() public returns(uint d) { 3 | return false ? 5 : 10; 4 | } 5 | } 6 | // ---- 7 | // f() -> 10 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/expressions/conditional_expression_true_literal.sol: -------------------------------------------------------------------------------- 1 | contract test { 2 | function f() public returns(uint d) { 3 | return true ? 5 : 10; 4 | } 5 | } 6 | // ---- 7 | // f() -> 5 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/expressions/conditional_expression_tuples.sol: -------------------------------------------------------------------------------- 1 | contract test { 2 | function f(bool cond) public returns (uint, uint) { 3 | return cond ? (1, 2) : (3, 4); 4 | } 5 | } 6 | // ---- 7 | // f(bool): true -> 1, 2 8 | // f(bool): false -> 3, 4 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/expressions/conditional_expression_with_return_values.sol: -------------------------------------------------------------------------------- 1 | contract test { 2 | function f(bool cond, uint v) public returns (uint a, uint b) { 3 | cond ? a = v : b = v; 4 | } 5 | } 6 | // ---- 7 | // f(bool,uint256): true, 20 -> 20, 0 8 | // f(bool,uint256): false, 20 -> 0, 20 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/expressions/exp_operator_const.sol: -------------------------------------------------------------------------------- 1 | contract test { 2 | function f() public returns(uint d) { return 2 ** 3; } 3 | } 4 | // ---- 5 | // f() -> 8 6 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/expressions/exp_operator_const_signed.sol: -------------------------------------------------------------------------------- 1 | contract test { 2 | function f() public returns(int d) { return (-2) ** 3; } 3 | } 4 | // ---- 5 | // f() -> -8 6 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/expressions/exp_zero_literal.sol: -------------------------------------------------------------------------------- 1 | contract test { 2 | function f() public returns(uint d) { return 0 ** 0; } 3 | } 4 | // ---- 5 | // f() -> 1 6 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/expressions/inc_dec_operators.sol: -------------------------------------------------------------------------------- 1 | contract test { 2 | uint8 x; 3 | uint v; 4 | function f() public returns (uint r) { 5 | uint a = 6; 6 | r = a; 7 | r += (a++) * 0x10; 8 | r += (++a) * 0x100; 9 | v = 3; 10 | r += (v++) * 0x1000; 11 | r += (++v) * 0x10000; 12 | } 13 | } 14 | // ---- 15 | // f() -> 0x053866 16 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/expressions/module_from_ternary_expression.sol: -------------------------------------------------------------------------------- 1 | ==== Source: A ==== 2 | contract D { 3 | } 4 | ==== Source: B ==== 5 | import "A" as M; 6 | 7 | contract C { 8 | function f() public pure returns (bool) { 9 | bool flag; 10 | ((flag = true) ? M : M).D; 11 | return flag; 12 | } 13 | } 14 | // ---- 15 | // f() -> true 16 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/expressions/tuple_from_ternary_expression.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public pure returns (bool){ 3 | bool flag; 4 | ((flag = true) ? (1, 2, 3) : (3, 2, 1)); 5 | return flag; 6 | } 7 | } 8 | // ---- 9 | // f() -> true 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/expressions/unary_too_long_literal.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public returns (bool) { 3 | return 4 | 0 < 5 | ~~84926290883049832306107864558384249403874903260938453235235091622489261765859; 6 | } 7 | } 8 | // ---- 9 | // f() -> true 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/expressions/uncalled_address_transfer_send.sol: -------------------------------------------------------------------------------- 1 | contract TransferTest { 2 | fallback() external payable { 3 | // This used to cause an ICE 4 | payable(this).transfer; 5 | } 6 | 7 | function f() pure public {} 8 | } 9 | // ---- 10 | // f() -> 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/externalContracts/_prbmath/LICENSE.md: -------------------------------------------------------------------------------- 1 | # WTFPL 2 | 3 | by Paul Razvan Berg (@PaulRBerg) 4 | 5 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 6 | 7 | 0. You just DO WHAT THE FUCK YOU WANT TO. 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/externalContracts/_prbmath/README.md: -------------------------------------------------------------------------------- 1 | Imported from https://github.com/hifi-finance/prb-math/commit/62021c1abc3413f20d0bdc8f941cf9f21d5a7d2d 2 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/externalContracts/_stringutils/README.md: -------------------------------------------------------------------------------- 1 | String utilities, originally from 2 | 3 | https://github.com/Arachnid/solidity-stringutils 4 | 5 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/externalSource/_external/external.sol: -------------------------------------------------------------------------------- 1 | contract External { 2 | } 3 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/externalSource/_external/external.sol=sol: -------------------------------------------------------------------------------- 1 | contract External { 2 | } 3 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/externalSource/_external/import.sol: -------------------------------------------------------------------------------- 1 | import "external.sol"; 2 | import "other_external.sol"; 3 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/externalSource/_external/import_with_subdir.sol: -------------------------------------------------------------------------------- 1 | import "subdir/import.sol"; 2 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/externalSource/_external/other_external.sol: -------------------------------------------------------------------------------- 1 | contract OtherExternal { 2 | } 3 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/externalSource/_external/subdir/import.sol: -------------------------------------------------------------------------------- 1 | import "sub_external.sol"; 2 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/externalSource/_external/subdir/sub_external.sol: -------------------------------------------------------------------------------- 1 | contract SubExternal { 2 | } 3 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/externalSource/_non_normalized_paths/a.sol: -------------------------------------------------------------------------------- 1 | contract A { 2 | } 3 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/externalSource/_non_normalized_paths/c.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | } 3 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/externalSource/_non_normalized_paths/d.sol: -------------------------------------------------------------------------------- 1 | contract D { 2 | } 3 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/externalSource/_relative_imports/D/d.sol: -------------------------------------------------------------------------------- 1 | contract D { 2 | } 3 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/externalSource/_relative_imports/c.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | } 3 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/externalSource/_relative_imports/dir/B/b.sol: -------------------------------------------------------------------------------- 1 | import {C} from "../../c.sol"; 2 | contract B { 3 | } 4 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/externalSource/_relative_imports/dir/G/g.sol: -------------------------------------------------------------------------------- 1 | import {B} from "../B/b.sol"; 2 | contract G { 3 | } 4 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/externalSource/_relative_imports/dir/a.sol: -------------------------------------------------------------------------------- 1 | contract A { 2 | } 3 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/externalSource/_relative_imports/dir/contract.sol: -------------------------------------------------------------------------------- 1 | import {A} from "./a.sol"; 2 | import {B} from "./B/b.sol"; 3 | import {C} from "../c.sol"; 4 | import {D} from "../D/d.sol"; 5 | import {G} from "./E/../F/../G/./g.sol"; 6 | import {H} from "../../../../_relative_imports/h.sol"; 7 | contract Contract { 8 | } 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/externalSource/_relative_imports/h.sol: -------------------------------------------------------------------------------- 1 | contract H { 2 | } 3 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/externalSource/_source_name_starting_with_dots/b.sol: -------------------------------------------------------------------------------- 1 | contract B { 2 | } 3 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/externalSource/_source_name_starting_with_dots/dir/a.sol: -------------------------------------------------------------------------------- 1 | contract A { 2 | } 3 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/externalSource/_source_name_starting_with_dots/dir/contract.sol: -------------------------------------------------------------------------------- 1 | import {A} from "./a.sol"; 2 | import {B} from "../b.sol"; 3 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/externalSource/_source_name_starting_with_dots/dot_a.sol: -------------------------------------------------------------------------------- 1 | contract Dot_A { 2 | } 3 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/externalSource/_source_name_starting_with_dots/dot_dot_b.sol: -------------------------------------------------------------------------------- 1 | contract Dot_Dot_B { 2 | } 3 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/externalSource/multiple_equals_signs.sol: -------------------------------------------------------------------------------- 1 | ==== ExternalSource: a=_external/external.sol=sol ==== 2 | import {External} from "a"; 3 | contract C { 4 | } 5 | // ---- 6 | // constructor() 7 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/externalSource/multiple_external_source.sol: -------------------------------------------------------------------------------- 1 | ==== ExternalSource: _external/external.sol ==== 2 | ==== ExternalSource: _external/other_external.sol ==== 3 | import {External} from "_external/external.sol"; 4 | import {OtherExternal} from "_external/other_external.sol"; 5 | contract C { 6 | } 7 | // ---- 8 | // constructor() 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/externalSource/multisource.sol: -------------------------------------------------------------------------------- 1 | ==== ExternalSource: _external/external.sol ==== 2 | ==== Source: s1.sol ==== 3 | import {External} from "_external/external.sol"; 4 | contract S1 { 5 | } 6 | ==== Source: s2.sol ==== 7 | import {S1} from "s1.sol"; 8 | contract C { 9 | } 10 | // ---- 11 | // constructor() 12 | 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/externalSource/source.sol: -------------------------------------------------------------------------------- 1 | ==== ExternalSource: _external/external.sol ==== 2 | import {External} from "_external/external.sol"; 3 | contract C { 4 | } 5 | // ---- 6 | // constructor() 7 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/externalSource/source_import.sol: -------------------------------------------------------------------------------- 1 | ==== ExternalSource: _external/external.sol ==== 2 | ==== ExternalSource: _external/other_external.sol ==== 3 | import {External} from "_external/external.sol"; 4 | import {OtherExternal} from "_external/other_external.sol"; 5 | contract C { 6 | } 7 | // ---- 8 | // constructor() 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/externalSource/source_import_subdir.sol: -------------------------------------------------------------------------------- 1 | ==== ExternalSource: _external/import_with_subdir.sol ==== 2 | ==== ExternalSource: subdir/import.sol=_external/subdir/import.sol ==== 3 | ==== ExternalSource: sub_external.sol=_external/subdir/sub_external.sol ==== 4 | import {SubExternal} from "sub_external.sol"; 5 | contract C { 6 | } 7 | // ---- 8 | // constructor() 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/externalSource/source_remapping.sol: -------------------------------------------------------------------------------- 1 | ==== ExternalSource: ExtSource.sol=_external/external.sol ==== 2 | ==== ExternalSource: /ExtSource.sol=_external/other_external.sol ==== 3 | import "ExtSource.sol"; 4 | import "/ExtSource.sol"; 5 | contract C { 6 | External _external; 7 | OtherExternal _otherExternal; 8 | } 9 | // ---- 10 | // constructor() 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/fallback/falback_return.sol: -------------------------------------------------------------------------------- 1 | contract A { 2 | uint public x; 3 | fallback () external { 4 | if (x == 2) return; 5 | x++; 6 | } 7 | } 8 | // ---- 9 | // () 10 | // x() -> 1 11 | // () 12 | // x() -> 2 13 | // () 14 | // x() -> 2 15 | // () 16 | // x() -> 2 17 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/fallback/inherited.sol: -------------------------------------------------------------------------------- 1 | contract A { 2 | uint data; 3 | fallback() external { data = 1; } 4 | function getData() public returns (uint r) { return data; } 5 | } 6 | contract B is A {} 7 | // ---- 8 | // getData() -> 0 9 | // (): 42 -> 10 | // getData() -> 1 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/freeFunctions/easy.sol: -------------------------------------------------------------------------------- 1 | function add(uint a, uint b) pure returns (uint) { 2 | return a + b; 3 | } 4 | 5 | contract C { 6 | function f(uint x) public pure returns (uint) { 7 | return add(x, 2); 8 | } 9 | } 10 | // ---- 11 | // f(uint256): 7 -> 9 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/freeFunctions/free_namesake_contract_function.sol: -------------------------------------------------------------------------------- 1 | function f() pure returns (uint) { return 1337; } 2 | contract C { 3 | function f() public pure returns (uint) { 4 | return f(); 5 | } 6 | } 7 | // ---- 8 | // f() -> FAILURE 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/freeFunctions/free_runtimecode.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | uint public x = 2; 3 | } 4 | 5 | function test() returns (bool) { 6 | return type(C).runtimeCode.length > 20; 7 | } 8 | 9 | contract D { 10 | function f() public returns (bool) { 11 | return test(); 12 | } 13 | } 14 | // ---- 15 | // f() -> true 16 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/freeFunctions/new_operator.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | uint public x = 2; 3 | } 4 | 5 | function test() returns (uint) { 6 | return (new C()).x(); 7 | } 8 | 9 | contract D { 10 | function f() public returns (uint) { 11 | return test(); 12 | } 13 | } 14 | // ---- 15 | // f() -> 2 16 | // gas legacy: 100211 17 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/freeFunctions/overloads.sol: -------------------------------------------------------------------------------- 1 | function f(uint) returns (uint) { 2 | return 2; 3 | } 4 | function f(string memory) returns (uint) { 5 | return 3; 6 | } 7 | 8 | contract C { 9 | function g() public returns (uint, uint) { 10 | return (f(2), f("abc")); 11 | } 12 | } 13 | // ---- 14 | // g() -> 2, 3 15 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/functionCall/bare_call_no_returndatacopy.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public returns (bool) { 3 | (bool success, ) = address(1).call(""); 4 | return success; 5 | } 6 | } 7 | // ---- 8 | // f() -> true 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/functionCall/call_function_returning_nothing_via_pointer.sol: -------------------------------------------------------------------------------- 1 | contract test { 2 | bool public flag = false; 3 | 4 | function f0() public { 5 | flag = true; 6 | } 7 | 8 | function f() public returns (bool) { 9 | function() internal x = f0; 10 | x(); 11 | return flag; 12 | } 13 | } 14 | // ---- 15 | // f() -> true 16 | // flag() -> true 17 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/functionCall/conditional_with_arguments.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function g(int x, int y) public pure returns (int) { return x - y; } 3 | function h(int y, int x) public pure returns (int) { return y - x; } 4 | 5 | function f() public pure returns (int) { 6 | return (false ? g : h)(2, 1); 7 | } 8 | } 9 | // ---- 10 | // f() -> 1 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/functionCall/creation_function_call_no_args.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | uint public i; 3 | constructor() { 4 | i = 2; 5 | } 6 | } 7 | contract D { 8 | function f() public returns (uint r) { 9 | return new C().i(); 10 | } 11 | } 12 | // ---- 13 | // f() -> 2 14 | // gas legacy: 100185 15 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/functionCall/disordered_named_args.sol: -------------------------------------------------------------------------------- 1 | contract test { 2 | function a(uint a, uint b, uint c) public returns (uint r) { r = a * 100 + b * 10 + c * 1; } 3 | function b() public returns (uint r) { r = a({c: 3, a: 1, b: 2}); } 4 | } 5 | // ---- 6 | // b() -> 123 7 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/functionCall/external_call.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >= 0.6.0; 2 | 3 | contract C { 4 | function g(uint n) external pure returns (uint) { 5 | return n + 1; 6 | } 7 | 8 | function f(uint n) public view returns (uint) { 9 | return this.g(2 * n); 10 | } 11 | } 12 | // ---- 13 | // g(uint256): 4 -> 5 14 | // f(uint256): 2 -> 5 15 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/functionCall/external_function.sol: -------------------------------------------------------------------------------- 1 | contract c { 2 | function f(uint256 a) public returns (uint256) { 3 | return a; 4 | } 5 | 6 | function test(uint256 a, uint256 b) 7 | external 8 | returns (uint256 r_a, uint256 r_b) 9 | { 10 | r_a = f(a + 7); 11 | r_b = b; 12 | } 13 | } 14 | // ---- 15 | // test(uint256,uint256): 2, 3 -> 9, 3 16 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/functionCall/inheritance/call_base.sol: -------------------------------------------------------------------------------- 1 | contract Base { 2 | function f(uint n) public returns (uint) { 3 | return 2 * n; 4 | } 5 | } 6 | 7 | contract Child is Base { 8 | function g(uint n) public returns (uint) { 9 | return f(n); 10 | } 11 | } 12 | // ---- 13 | // g(uint256): 4 -> 8 14 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/functionCall/inheritance/call_base_explicit.sol: -------------------------------------------------------------------------------- 1 | contract Base { 2 | function f(uint n) public returns (uint) { 3 | return 2 * n; 4 | } 5 | } 6 | 7 | contract Child is Base { 8 | function g(uint n) public returns (uint) { 9 | return Base.f(n); 10 | } 11 | } 12 | // ---- 13 | // g(uint256): 4 -> 8 14 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/functionCall/multiple_return_values.sol: -------------------------------------------------------------------------------- 1 | contract test { 2 | function run(bool x1, uint x2) public returns(uint y1, bool y2, uint y3) { 3 | y1 = x2; y2 = x1; 4 | } 5 | } 6 | // ---- 7 | // run(bool,uint256): true, 0xcd -> 0xcd, true, 0 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/functionCall/named_args.sol: -------------------------------------------------------------------------------- 1 | contract test { 2 | function a(uint a, uint b, uint c) public returns (uint r) { r = a * 100 + b * 10 + c * 1; } 3 | function b() public returns (uint r) { r = a({a: 1, b: 2, c: 3}); } 4 | function c() public returns (uint r) { r = a({b: 2, c: 3, a: 1}); } 5 | } 6 | // ---- 7 | // b() -> 123 8 | // c() -> 123 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/functionCall/transaction_status.sol: -------------------------------------------------------------------------------- 1 | contract test { 2 | function f() public { } 3 | function g() public { revert(); } 4 | function h() public { assert(false); } 5 | } 6 | // ---- 7 | // f() -> 8 | // g() -> FAILURE 9 | // h() -> FAILURE, hex"4e487b71", 0x01 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/functionCall/value_test.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public payable returns (uint) { 3 | return msg.value; 4 | } 5 | } 6 | // ---- 7 | // f(), 1 ether -> 1000000000000000000 8 | // f(), 1 wei -> 1 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/functionTypes/address_member.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public view returns (address a1, address a2) { 3 | a1 = this.f.address; 4 | this.f.address; 5 | [this.f.address][0]; 6 | a2 = [this.f.address][0]; 7 | } 8 | } 9 | // ---- 10 | // f() -> 0xc06afe3a8444fc0004668591e8306bfb9968e79e, 0xc06afe3a8444fc0004668591e8306bfb9968e79e 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/functionTypes/duplicated_function_definition_with_same_id_in_internal_dispatcher.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function a() internal {} 3 | function f() public { 4 | function() ptr1 = a; 5 | function() ptr2 = a; 6 | } 7 | } 8 | // ---- 9 | // f() 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/functionTypes/function_delete_stack.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function a() public returns (uint256) { 3 | return 7; 4 | } 5 | 6 | function test() public returns (uint256) { 7 | function() returns (uint256) y = a; 8 | delete y; 9 | y(); 10 | } 11 | } 12 | // ---- 13 | // test() -> FAILURE, hex"4e487b71", 0x51 14 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/functionTypes/selector_assignment_expression.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | bool public z; 3 | function f() public { 4 | ((z = true) ? this.f : this.f).selector; 5 | } 6 | } 7 | 8 | // ---- 9 | // f() 10 | // z() -> true 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/functionTypes/selector_expression_side_effect.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | uint x; 3 | function f() public returns (uint256) { 4 | h().f.selector; 5 | return x; 6 | } 7 | function h() public returns (C) { 8 | x = 42; 9 | return this; 10 | } 11 | } 12 | // ---- 13 | // f() -> 42 14 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/functionTypes/ternary_contract_internal_function.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() internal pure returns(uint256) { return 1;} 3 | function g() internal pure returns(uint256) { return 2; } 4 | function test(bool b) public returns(uint256) { 5 | return (b ? C.f : C.g)(); 6 | } 7 | } 8 | // ---- 9 | // test(bool): true -> 1 10 | // test(bool): false -> 2 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/functionTypes/ternary_contract_public_function.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public pure returns(uint256) { return 1; } 3 | function g() public pure returns(uint256) { return 2; } 4 | function test(bool b) public returns(uint256) { 5 | return (b ? C.f : C.g)(); 6 | } 7 | } 8 | // ---- 9 | // test(bool): true -> 1 10 | // test(bool): false -> 2 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/functionTypes/uninitialized_internal_storage_function_call.sol: -------------------------------------------------------------------------------- 1 | contract Test { 2 | function() internal x; 3 | 4 | function f() public returns (uint256 r) { 5 | x(); 6 | return 2; 7 | } 8 | } 9 | // ---- 10 | // f() -> FAILURE, hex"4e487b71", 0x51 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/getters/arrays.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | uint8[][2] public a; 3 | constructor() { 4 | a[1].push(3); 5 | a[1].push(4); 6 | } 7 | } 8 | // ---- 9 | // a(uint256,uint256): 0, 0 -> FAILURE 10 | // a(uint256,uint256): 1, 0 -> 3 11 | // a(uint256,uint256): 1, 1 -> 4 12 | // a(uint256,uint256): 2, 0 -> FAILURE 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/getters/bytes.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | bytes public b; 3 | constructor() { 4 | b = "abc"; 5 | } 6 | } 7 | // ---- 8 | // b() -> 0x20, 0x03, 0x6162630000000000000000000000000000000000000000000000000000000000 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/getters/mapping.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | mapping(uint => mapping(uint => uint)) public x; 3 | constructor() { 4 | x[1][2] = 3; 5 | } 6 | } 7 | // ---- 8 | // x(uint256,uint256): 1, 2 -> 3 9 | // x(uint256,uint256): 0, 0 -> 0 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/getters/mapping_with_names.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | mapping(uint a => mapping(uint b => uint c)) public x; 3 | constructor() { 4 | x[1][2] = 3; 5 | } 6 | } 7 | // ---- 8 | // x(uint256,uint256): 1, 2 -> 3 9 | // x(uint256,uint256): 0, 0 -> 0 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/immutable/assign_at_declaration.sol: -------------------------------------------------------------------------------- 1 | contract A { 2 | uint8 immutable a = 2; 3 | function f() public view returns (uint) { 4 | return a; 5 | } 6 | } 7 | // ---- 8 | // f() -> 2 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/immutable/assign_from_immutables.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | uint immutable public a; 3 | uint immutable public b; 4 | uint immutable public c; 5 | uint immutable public d; 6 | 7 | constructor() { 8 | a = 1; 9 | b = a; 10 | c = b; 11 | d = c; 12 | } 13 | } 14 | // ---- 15 | // a() -> 1 16 | // b() -> 1 17 | // c() -> 1 18 | // d() -> 1 19 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/immutable/delete.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | uint8 immutable public a; 3 | uint8 immutable public b = 0x42; 4 | uint public c; 5 | 6 | constructor() { 7 | delete a; 8 | delete b; 9 | c = b * 2 + a; 10 | } 11 | } 12 | // ---- 13 | // a() -> 0 14 | // b() -> 0 15 | // c() -> 0 16 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/immutable/fun_read_in_ctor.sol: -------------------------------------------------------------------------------- 1 | contract A { 2 | uint8 immutable a; 3 | uint8 x; 4 | 5 | constructor() { 6 | a = 3; 7 | x = readA(); 8 | } 9 | 10 | function readX() public view returns (uint8) { 11 | return x; 12 | } 13 | 14 | function readA() public view returns (uint8) { 15 | return a; 16 | } 17 | } 18 | // ---- 19 | // readX() -> 3 20 | // readA() -> 3 21 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/immutable/getter.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | uint immutable public x = 1; 3 | } 4 | // ---- 5 | // x() -> 1 6 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/immutable/increment_decrement.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | int immutable x = 1; 3 | int immutable y = 3; 4 | 5 | constructor() { 6 | x--; 7 | --x; 8 | y++; 9 | ++y; 10 | --y; 11 | } 12 | 13 | function f() public view returns (int, int) { 14 | return (x, y); 15 | } 16 | } 17 | // ---- 18 | // f() -> -1, 4 19 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/immutable/internal_function_pointer.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function() internal view returns(uint256) immutable z; 3 | constructor() { 4 | z = f; 5 | } 6 | function f() public view returns (uint256) { 7 | return 7; 8 | } 9 | function callZ() public view returns (uint) { 10 | return z(); 11 | } 12 | } 13 | // ---- 14 | // f() -> 7 15 | // callZ() -> 7 16 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/immutable/read_in_ctor.sol: -------------------------------------------------------------------------------- 1 | contract A { 2 | uint8 immutable a; 3 | uint8 x; 4 | 5 | constructor() { 6 | a = 3; 7 | x = a; 8 | } 9 | 10 | function readX() public view returns (uint8) { 11 | return x; 12 | } 13 | } 14 | // ---- 15 | // readX() -> 3 16 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/immutable/stub.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | uint256 immutable x; 3 | uint256 immutable y; 4 | constructor() { 5 | x = 42; 6 | y = 23; 7 | } 8 | function f() public view returns (uint256, uint256) { 9 | return (x+x,y); 10 | } 11 | } 12 | // ---- 13 | // f() -> 84, 23 14 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/immutable/uninitialized.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | uint immutable u; 3 | bool immutable b; 4 | address immutable a; 5 | 6 | function get() public returns (uint, bool, address) { 7 | return (u, b, a); 8 | } 9 | } 10 | // ---- 11 | // get() -> 0, false, 0x0 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/inheritance/inherited_constant_state_var.sol: -------------------------------------------------------------------------------- 1 | contract A { 2 | uint256 constant x = 7; 3 | } 4 | 5 | 6 | contract B is A { 7 | function f() public returns (uint256) { 8 | return A.x; 9 | } 10 | } 11 | // ---- 12 | // f() -> 7 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/inheritance/inherited_function.sol: -------------------------------------------------------------------------------- 1 | contract A { 2 | function f() internal virtual returns (uint256) { 3 | return 1; 4 | } 5 | } 6 | 7 | 8 | contract B is A { 9 | function f() internal override returns (uint256) { 10 | return 2; 11 | } 12 | 13 | function g() public returns (uint256) { 14 | return A.f(); 15 | } 16 | } 17 | // ---- 18 | // g() -> 1 19 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/inheritance/inherited_function_from_a_library.sol: -------------------------------------------------------------------------------- 1 | library A { 2 | function f() internal returns (uint256) { 3 | return 1; 4 | } 5 | } 6 | 7 | 8 | contract B { 9 | function f() internal returns (uint256) { 10 | return 2; 11 | } 12 | 13 | function g() public returns (uint256) { 14 | return A.f(); 15 | } 16 | } 17 | // ---- 18 | // g() -> 1 19 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/inheritance/pass_dynamic_arguments_to_the_base.sol: -------------------------------------------------------------------------------- 1 | contract Base { 2 | constructor(uint256 i) { 3 | m_i = i; 4 | } 5 | 6 | uint256 public m_i; 7 | } 8 | 9 | 10 | contract Derived is Base { 11 | constructor(uint256 i) Base(i) {} 12 | } 13 | 14 | 15 | contract Final is Derived(4) {} 16 | 17 | // ---- 18 | // m_i() -> 4 19 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/inlineAssembly/blobhash.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public view returns (bytes32 ret) { 3 | assembly { 4 | ret := blobhash(0) 5 | } 6 | } 7 | } 8 | // ==== 9 | // EVMVersion: >=cancun 10 | // ---- 11 | // f() -> 0x0100000000000000000000000000000000000000000000000000000000000001 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/inlineAssembly/calldata_array_assign_dynamic.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(uint[2][] calldata x) public returns (uint[2][] memory r) { 3 | assembly { x.offset := 0x44 x.length := 2 } 4 | r = x; 5 | } 6 | } 7 | // ---- 8 | // f(uint256[2][]): 0x0, 1, 8, 7, 6, 5 -> 0x20, 2, 8, 7, 6, 5 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/inlineAssembly/calldata_array_assign_static.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(uint[2][2] calldata x) public returns (uint[2][2] memory r) { 3 | assembly { x := 0x24 } 4 | r = x; 5 | } 6 | } 7 | // ---- 8 | // f(uint256[2][2]): 0x0, 8, 7, 6, 5 -> 8, 7, 6, 5 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/inlineAssembly/calldata_assign.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(bytes calldata x) public returns (bytes memory) { 3 | assembly { x.offset := 1 x.length := 3 } 4 | return x; 5 | } 6 | } 7 | // ---- 8 | // f(bytes): 0x20, 0, 0 -> 0x20, 3, 0x5754f80000000000000000000000000000000000000000000000000000000000 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/inlineAssembly/calldata_assign_from_nowhere.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public pure returns (bytes calldata x) { 3 | assembly { x.offset := 0 x.length := 4 } 4 | } 5 | } 6 | // ---- 7 | // f() -> 0x20, 4, 0x26121ff000000000000000000000000000000000000000000000000000000000 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/inlineAssembly/chainid.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public returns (uint id) { 3 | assembly { 4 | id := chainid() 5 | } 6 | } 7 | } 8 | // ==== 9 | // EVMVersion: >=istanbul 10 | // ---- 11 | // f() -> 1 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/inlineAssembly/difficulty.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public view returns (uint ret) { 3 | assembly { 4 | ret := difficulty() 5 | } 6 | } 7 | } 8 | // ==== 9 | // EVMVersion: 200000000 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/inlineAssembly/external_identifier_access_shadowing.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public returns (uint x) { 3 | assembly { 4 | function g() -> f { f := 2 } 5 | x := g() 6 | } 7 | } 8 | } 9 | // ---- 10 | // f() -> 2 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/inlineAssembly/function_name_clash.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public pure returns (uint r) { 3 | assembly { function f() -> x { x := 1 } r := f() } 4 | } 5 | function g() public pure returns (uint r) { 6 | assembly { function f() -> x { x := 2 } r := f() } 7 | } 8 | } 9 | // ---- 10 | // f() -> 1 11 | // g() -> 2 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/inlineAssembly/inline_assembly_if.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(uint256 a) public returns (uint256 b) { 3 | assembly { 4 | if gt(a, 1) { 5 | b := 2 6 | } 7 | } 8 | } 9 | } 10 | // ---- 11 | // f(uint256): 0 -> 0 12 | // f(uint256): 1 -> 0 13 | // f(uint256): 2 -> 2 14 | // f(uint256): 3 -> 2 15 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/inlineAssembly/inline_assembly_read_and_write_stack.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public returns (uint256 r) { 3 | for (uint256 x = 0; x < 10; ++x) 4 | assembly { 5 | r := add(r, x) 6 | } 7 | } 8 | } 9 | // ---- 10 | // f() -> 45 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/inlineAssembly/inline_assembly_write_to_stack.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public returns (uint256 r, bytes32 r2) { 3 | assembly { 4 | r := 7 5 | r2 := "abcdef" 6 | } 7 | } 8 | } 9 | // ---- 10 | // f() -> 7, "abcdef" 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/inlineAssembly/inlineasm_empty_let.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public pure returns (uint a, uint b) { 3 | assembly { 4 | let x 5 | let y, z 6 | a := x 7 | b := z 8 | } 9 | } 10 | } 11 | // ---- 12 | // f() -> 0, 0 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/inlineAssembly/keccak256_assembly.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public pure returns (bytes32 ret) { 3 | assembly { 4 | ret := keccak256(0, 0) 5 | } 6 | } 7 | } 8 | // ---- 9 | // f() -> 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/inlineAssembly/leave.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public pure returns (uint w) { 3 | assembly { 4 | function f() -> t { 5 | t := 2 6 | leave 7 | t := 9 8 | } 9 | w := f() 10 | } 11 | } 12 | } 13 | // ---- 14 | // f() -> 2 15 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/inlineAssembly/prevrandao.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public view returns (uint ret) { 3 | assembly { 4 | ret := prevrandao() 5 | } 6 | } 7 | } 8 | // ==== 9 | // EVMVersion: >=paris 10 | // ---- 11 | // f() -> 0xa86c2e601b6c44eb4848f7d23d9df3113fbcac42041c49cbed5000cb4f118777 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/inlineAssembly/selfbalance.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public payable returns (uint ret) { 3 | assembly { 4 | ret := selfbalance() 5 | } 6 | } 7 | } 8 | // ==== 9 | // EVMVersion: >=istanbul 10 | // ---- 11 | // f(), 254 wei -> 254 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/inlineAssembly/shadowing_local_function_opcode.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function add(uint, uint) public pure returns (uint) { return 7; } 3 | function g() public pure returns (uint x, uint y) { 4 | x = add(1, 2); 5 | assembly { 6 | y := add(1, 2) 7 | } 8 | } 9 | } 10 | // ---- 11 | // g() -> 7, 3 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/inlineAssembly/transient_storage_creation.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | constructor() { 3 | uint x; 4 | assembly { 5 | tstore(0, 42) 6 | x := tload(0) 7 | } 8 | assert(x == 42); 9 | } 10 | } 11 | // ==== 12 | // EVMVersion: >=cancun 13 | // ---- 14 | // constructor() -> 15 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/inlineAssembly/truefalse.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public returns (uint x, uint y) { 3 | assembly { 4 | x := true 5 | y := false 6 | } 7 | } 8 | } 9 | // ---- 10 | // f() -> 1, 0 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/integer/many_local_variables.sol: -------------------------------------------------------------------------------- 1 | contract test { 2 | function run(uint x1, uint x2, uint x3) public returns(uint y) { 3 | uint8 a = 0x1; uint8 b = 0x10; uint16 c = 0x100; 4 | y = a + b + c + x1 + x2 + x3; 5 | y += b + x2; 6 | } 7 | } 8 | // ---- 9 | // run(uint256,uint256,uint256): 0x1000, 0x10000, 0x100000 -> 0x121121 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/integer/small_signed_types.sol: -------------------------------------------------------------------------------- 1 | contract test { 2 | function run() public returns(int256 y) { 3 | return -int32(10) * -int64(20); 4 | } 5 | } 6 | // ---- 7 | // run() -> 200 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/isoltestTesting/balance_with_balance.sol: -------------------------------------------------------------------------------- 1 | contract ClientReceipt { 2 | constructor() payable {} 3 | } 4 | // ---- 5 | // constructor(), 1000 wei -> 6 | // balance -> 1000 7 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/isoltestTesting/balance_with_balance2.sol: -------------------------------------------------------------------------------- 1 | contract ClientReceipt { 2 | constructor() payable {} 3 | } 4 | // ---- 5 | // constructor(), 1 ether -> 6 | // balance -> 1000000000000000000 7 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/isoltestTesting/balance_without_balance.sol: -------------------------------------------------------------------------------- 1 | contract ClientReceipt { 2 | } 3 | // ---- 4 | // balance -> 0 5 | // balance: 0x0000000000000000000000000000000000000000 -> 0 6 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/isoltestTesting/builtins.sol: -------------------------------------------------------------------------------- 1 | contract SmokeTest { 2 | } 3 | // ---- 4 | // isoltest_builtin_test -> 0x1234 5 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/isoltestTesting/storage/storage_empty.sol: -------------------------------------------------------------------------------- 1 | contract StorageEmpty { 2 | } 3 | // ---- 4 | // storageEmpty -> 1 5 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/isoltestTesting/storage/storage_nonempty.sol: -------------------------------------------------------------------------------- 1 | contract StorageNotEmpty { 2 | uint256 x; 3 | function set(uint256 _a) public { x = _a; } 4 | } 5 | // ---- 6 | // storageEmpty -> 1 7 | // set(uint256): 1 -> 8 | // storageEmpty -> 0 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/libraries/internal_call_unattached_with_parentheses.sol: -------------------------------------------------------------------------------- 1 | library L { 2 | function f() internal returns (uint) { 3 | return 3; 4 | } 5 | } 6 | 7 | contract C { 8 | function foo() public returns (uint) { 9 | return (L.f)(); 10 | } 11 | } 12 | // ---- 13 | // foo() -> 3 14 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/libraries/internal_library_function_pointer.sol: -------------------------------------------------------------------------------- 1 | library L { 2 | function f() internal returns (uint) { 3 | return 66; 4 | } 5 | } 6 | 7 | contract C { 8 | function g() public returns (uint) { 9 | function() internal returns(uint) ptr; 10 | ptr = L.f; 11 | return ptr(); 12 | } 13 | } 14 | // ---- 15 | // g() -> 66 16 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/libraries/library_call_in_homestead.sol: -------------------------------------------------------------------------------- 1 | library Lib { function m() public returns (address) { return msg.sender; } } 2 | contract Test { 3 | address public sender; 4 | function f() public { 5 | sender = Lib.m(); 6 | } 7 | } 8 | // ==== 9 | // EVMVersion: >=homestead 10 | // ---- 11 | // library: Lib 12 | // f() -> 13 | // sender() -> 0x1212121212121212121212121212120000000012 14 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/libraries/library_enum_as_an_expression.sol: -------------------------------------------------------------------------------- 1 | library Arst { 2 | enum Foo {Things, Stuff} 3 | } 4 | 5 | 6 | contract Tsra { 7 | function f() public returns (uint256) { 8 | Arst.Foo; 9 | return 1; 10 | } 11 | } 12 | // ---- 13 | // f() -> 1 14 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/libraries/library_stray_values.sol: -------------------------------------------------------------------------------- 1 | library Lib { function m(uint x, uint y) public returns (uint) { return x * y; } } 2 | contract Test { 3 | function f(uint x) public returns (uint) { 4 | Lib; 5 | Lib.m; 6 | return x + 9; 7 | } 8 | } 9 | // ---- 10 | // library: Lib 11 | // f(uint256): 33 -> 0x2a 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/libraries/library_struct_as_an_expression.sol: -------------------------------------------------------------------------------- 1 | library Arst { 2 | struct Foo { 3 | int256 Things; 4 | int256 Stuff; 5 | } 6 | } 7 | 8 | 9 | contract Tsra { 10 | function f() public returns (uint256) { 11 | Arst.Foo; 12 | return 1; 13 | } 14 | } 15 | // ---- 16 | // f() -> 1 17 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/libraries/payable_function_calls_library.sol: -------------------------------------------------------------------------------- 1 | library L { 2 | function f() public returns (uint) { return 7; } 3 | } 4 | contract C { 5 | function f() public payable returns (uint) { 6 | return L.f(); 7 | } 8 | } 9 | // ---- 10 | // library: L 11 | // f(): 27 -> 7 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/libraries/stub.sol: -------------------------------------------------------------------------------- 1 | library L { 2 | function f(uint256 v) external returns (uint256) { return v*v; } 3 | } 4 | contract C { 5 | function g(uint256 v) external returns (uint256) { 6 | return L.f(v); 7 | } 8 | } 9 | // ---- 10 | // library: L 11 | // g(uint256): 1 -> 1 12 | // g(uint256): 2 -> 4 13 | // g(uint256): 4 -> 16 14 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/libraries/stub_internal.sol: -------------------------------------------------------------------------------- 1 | library L { 2 | function f(uint256 v) internal returns (uint256) { return v*v; } 3 | } 4 | contract C { 5 | function g(uint256 v) external returns (uint256) { 6 | return L.f(v); 7 | } 8 | } 9 | // ---- 10 | // g(uint256): 1 -> 1 11 | // g(uint256): 2 -> 4 12 | // g(uint256): 4 -> 16 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/libraries/using_for_function_on_int.sol: -------------------------------------------------------------------------------- 1 | library D { 2 | function double(uint self) public returns (uint) { return 2 * self; } 3 | } 4 | contract C { 5 | using D for uint; 6 | function f(uint a) public returns (uint) { 7 | return a.double(); 8 | } 9 | } 10 | // ---- 11 | // library: D 12 | // f(uint256): 9 -> 18 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/literals/denominations.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | uint constant x = 1 ether + 1 gwei + 1 wei; 3 | 4 | function f() public view returns(uint) { return x; } 5 | } 6 | // ---- 7 | // f() -> 1000000001000000001 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/literals/ether.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | uint constant x = 1 ether; 3 | 4 | function f() public view returns(uint) { return x; } 5 | } 6 | // ---- 7 | // f() -> 1000000000000000000 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/literals/gwei.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | uint constant x = 1 gwei; 3 | 4 | function f() public view returns(uint) { return x; } 5 | } 6 | // ---- 7 | // f() -> 1000000000 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/literals/hex_string_with_non_printable_characters.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public pure returns (bytes32 result) { 3 | assembly { 4 | result := hex"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" 5 | } 6 | } 7 | } 8 | // ---- 9 | // f() -> 0x000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/literals/hex_string_with_underscore.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public pure returns(bytes memory) { 3 | return hex"12_34_5678_9A"; 4 | } 5 | } 6 | // ---- 7 | // f() -> 32, 5, left(0x123456789A) 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/literals/wei.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | uint constant x = 1 wei; 3 | 4 | function f() public view returns(uint) { return x; } 5 | } 6 | // ---- 7 | // f() -> 1 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/modifiers/function_modifier.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function getOne() public payable nonFree returns (uint256 r) { 3 | return 1; 4 | } 5 | 6 | modifier nonFree { 7 | if (msg.value > 0) _; 8 | } 9 | } 10 | // ---- 11 | // getOne() -> 0 12 | // getOne(), 1 wei -> 1 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/modifiers/function_modifier_empty.sol: -------------------------------------------------------------------------------- 1 | abstract contract A { 2 | function f() public mod returns (bool r) { 3 | return true; 4 | } 5 | 6 | modifier mod virtual; 7 | } 8 | 9 | 10 | contract C is A { 11 | modifier mod override { 12 | if (false) _; 13 | } 14 | } 15 | // ---- 16 | // f() -> false 17 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/modifiers/function_modifier_loop_viair.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | modifier repeat(uint256 count) { 3 | uint256 i; 4 | for (i = 0; i < count; ++i) _; 5 | } 6 | 7 | function f() public repeat(10) returns (uint256 r) { 8 | r += 1; 9 | } 10 | } 11 | // ==== 12 | // compileViaYul: true 13 | // ---- 14 | // f() -> 1 15 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/modifiers/function_modifier_multi_invocation_viair.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | modifier repeat(bool twice) { 3 | if (twice) _; 4 | _; 5 | } 6 | 7 | function f(bool twice) public repeat(twice) returns (uint256 r) { 8 | r += 1; 9 | } 10 | } 11 | // ==== 12 | // compileViaYul: true 13 | // ---- 14 | // f(bool): false -> 1 15 | // f(bool): true -> 1 16 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/modifiers/function_modifier_multiple_times.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | uint256 public a; 3 | modifier mod(uint256 x) { 4 | a += x; 5 | _; 6 | } 7 | 8 | function f(uint256 x) public mod(2) mod(5) mod(x) returns (uint256) { 9 | return a; 10 | } 11 | } 12 | // ---- 13 | // f(uint256): 3 -> 10 14 | // a() -> 10 15 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/modifiers/function_modifier_overriding.sol: -------------------------------------------------------------------------------- 1 | contract A { 2 | function f() public mod returns (bool r) { 3 | return true; 4 | } 5 | 6 | modifier mod virtual { 7 | _; 8 | } 9 | } 10 | 11 | 12 | contract C is A { 13 | modifier mod override { 14 | if (false) _; 15 | } 16 | } 17 | // ---- 18 | // f() -> false 19 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/modifiers/function_modifier_return_reference.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | modifier m1(uint value) { 3 | _; 4 | } 5 | modifier m2(uint value) { 6 | _; 7 | } 8 | 9 | function f() public m1(x = 2) m2(y = 3) returns (uint x, uint y) { 10 | } 11 | } 12 | // ---- 13 | // f() -> 2, 3 14 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/modifiers/function_return_parameter.sol: -------------------------------------------------------------------------------- 1 | // The IR of this contract used to throw 2 | contract B { 3 | function f(uint8 a) mod1(a, true) mod2(r) pure public returns (bytes7 r) { } 4 | modifier mod1(uint a, bool b) { if (b) _; } 5 | modifier mod2(bytes7 a) { while (a == "1234567") _; } 6 | } 7 | // ---- 8 | // f(uint8): 5 -> 0x00 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/modifiers/modifer_recursive.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | uint public called; 3 | modifier mod1 { 4 | called++; 5 | _; 6 | } 7 | function f(uint x) public mod1 returns (uint256 r) { 8 | return x == 0 ? 2 : f(x - 1)**2; 9 | } 10 | } 11 | // ---- 12 | // called() -> 0x00 13 | // f(uint256): 5 -> 0x0100000000 14 | // called() -> 6 15 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/modifiers/modifier_in_constructor_ice.sol: -------------------------------------------------------------------------------- 1 | // The IR of this contract used to throw 2 | contract A { modifier m1{_;} } 3 | contract B is A { constructor() A() m1{} } 4 | // ---- 5 | // constructor() -> 6 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/modifiers/modifier_init_return.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | modifier m(bool condition) { 3 | if (condition) _; 4 | } 5 | 6 | function f(uint x) public m(x >= 10) returns (uint[5] memory r) { 7 | r[2] = 3; 8 | } 9 | } 10 | // ---- 11 | // f(uint256): 9 -> 0x00, 0x00, 0x00, 0x00, 0x00 12 | // f(uint256): 10 -> 0x00, 0x00, 3, 0x00, 0x00 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/modifiers/modifiers_in_construction_context.sol: -------------------------------------------------------------------------------- 1 | // The IR of this contract used to throw 2 | contract A { 3 | constructor() m1 { } 4 | modifier m1 { _; } 5 | } 6 | contract B is A { 7 | modifier m2 { _; } 8 | constructor() A() m1 m2 { } 9 | } 10 | // ---- 11 | // constructor() -> 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/modifiers/return_does_not_skip_modifier.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | uint256 public x; 3 | modifier setsx { 4 | _; 5 | x = 9; 6 | } 7 | 8 | function f() public setsx returns (uint256) { 9 | return 2; 10 | } 11 | } 12 | // ---- 13 | // x() -> 0 14 | // f() -> 2 15 | // x() -> 9 16 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/multiSource/circular_import.sol: -------------------------------------------------------------------------------- 1 | ==== Source: s1.sol ==== 2 | import {f as g} from "s2.sol"; 3 | function f() pure returns (uint) { return 1; } 4 | ==== Source: s2.sol ==== 5 | import {f as g} from "s1.sol"; 6 | function f() pure returns (uint) { return 2; } 7 | contract C { 8 | function foo() public pure returns (uint) { 9 | return f() - g(); 10 | } 11 | } 12 | // ---- 13 | // foo() -> 1 14 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/multiSource/import.sol: -------------------------------------------------------------------------------- 1 | ==== Source: A ==== 2 | contract A { 3 | function g(uint256 x) public view returns(uint256) { return x + 1; } 4 | } 5 | ==== Source: B ==== 6 | import "A"; 7 | contract B is A { 8 | function f(uint256 x) public view returns(uint256) { return x; } 9 | } 10 | // ---- 11 | // f(uint256): 1337 -> 1337 12 | // g(uint256): 1337 -> 1338 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/multiSource/reimport_imported_function.sol: -------------------------------------------------------------------------------- 1 | ==== Source: s1.sol ==== 2 | function f() pure returns (uint) { return 1337; } 3 | ==== Source: s2.sol ==== 4 | import {f as g} from "s1.sol"; 5 | ==== Source: s3.sol ==== 6 | import {g as h} from "s2.sol"; 7 | contract C { 8 | function foo() public pure returns (uint) { 9 | return h(); 10 | } 11 | } 12 | // ---- 13 | // foo() -> 1337 14 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/operators/shifts/shift_cleanup.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public returns (uint16 x) { 3 | unchecked { 4 | x = 0xffff; 5 | x += 32; 6 | x <<= 8; 7 | x >>= 16; 8 | } 9 | } 10 | } 11 | // ---- 12 | // f() -> 0x0 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/operators/shifts/shift_cleanup_garbled.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public returns (uint8 x) { 3 | assembly { 4 | x := 0xffff 5 | } 6 | x >>= 8; 7 | } 8 | } 9 | // ---- 10 | // f() -> 0x0 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/operators/shifts/shift_constant_left.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | uint256 public a = 0x42 << 8; 3 | } 4 | // ---- 5 | // a() -> 0x4200 6 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/operators/shifts/shift_constant_left_assignment.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public returns (uint256 a) { 3 | a = 0x42; 4 | a <<= 8; 5 | } 6 | } 7 | // ---- 8 | // f() -> 0x4200 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/operators/shifts/shift_constant_right.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | uint256 public a = 0x4200 >> 8; 3 | } 4 | // ---- 5 | // a() -> 0x42 6 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/operators/shifts/shift_constant_right_assignment.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public returns (uint256 a) { 3 | a = 0x4200; 4 | a >>= 8; 5 | } 6 | } 7 | // ---- 8 | // f() -> 0x42 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/operators/shifts/shift_left_larger_type.sol: -------------------------------------------------------------------------------- 1 | // This basically tests proper cleanup and conversion. It should not convert x to int8. 2 | contract C { 3 | function f() public returns (int8) { 4 | uint8 x = 254; 5 | int8 y = 1; 6 | return y << x; 7 | } 8 | } 9 | // ---- 10 | // f() -> 0 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/operators/shifts/shift_left_uint8.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(uint8 a, uint8 b) public returns (uint256) { 3 | return a << b; 4 | } 5 | } 6 | // ---- 7 | // f(uint8,uint8): 0x66, 0x0 -> 0x66 8 | // f(uint8,uint8): 0x66, 0x8 -> 0 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/operators/shifts/shift_negative_constant_left.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | int256 public a = -0x42 << 8; 3 | } 4 | // ---- 5 | // a() -> -16896 6 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/operators/shifts/shift_negative_constant_right.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | int256 public a = -0x4200 >> 8; 3 | } 4 | // ---- 5 | // a() -> -66 6 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/operators/shifts/shift_right_assignment.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(uint256 a, uint256 b) public returns (uint256) { 3 | a >>= b; 4 | return a; 5 | } 6 | } 7 | // ---- 8 | // f(uint256,uint256): 0x4266, 0x0 -> 0x4266 9 | // f(uint256,uint256): 0x4266, 0x8 -> 0x42 10 | // f(uint256,uint256): 0x4266, 0x10 -> 0 11 | // f(uint256,uint256): 0x4266, 0x11 -> 0 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/operators/shifts/shift_right_uint32.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(uint32 a, uint32 b) public returns (uint256) { 3 | return a >> b; 4 | } 5 | } 6 | // ---- 7 | // f(uint32,uint32): 0x4266, 0x0 -> 0x4266 8 | // f(uint32,uint32): 0x4266, 0x8 -> 0x42 9 | // f(uint32,uint32): 0x4266, 0x10 -> 0 10 | // f(uint32,uint32): 0x4266, 0x11 -> 0 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/operators/shifts/shift_right_uint8.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(uint8 a, uint8 b) public returns (uint256) { 3 | return a >> b; 4 | } 5 | } 6 | // ---- 7 | // f(uint8,uint8): 0x66, 0x0 -> 0x66 8 | // f(uint8,uint8): 0x66, 0x8 -> 0x0 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/operators/shifts/shift_underflow_negative_rvalue.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(int256 a, uint256 b) public returns (int256) { 3 | return a << b; 4 | } 5 | 6 | function g(int256 a, uint256 b) public returns (int256) { 7 | return a >> b; 8 | } 9 | } 10 | // ---- 11 | // f(int256,uint256): 1, -1 -> 0 12 | // g(int256,uint256): 1, -1 -> 0 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/operators/shifts/shifts.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(uint x) public returns (uint y) { 3 | assembly { y := shl(2, x) } 4 | } 5 | } 6 | // ==== 7 | // EVMVersion: >=constantinople 8 | // ---- 9 | // f(uint256): 7 -> 28 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/receive/empty_calldata_calls_receive.sol: -------------------------------------------------------------------------------- 1 | contract A { 2 | uint public x; 3 | receive () external payable { ++x; } 4 | } 5 | // ---- 6 | // x() -> 0 7 | // () 8 | // x() -> 1 9 | // (), 1 wei 10 | // x() -> 2 11 | // x(), 1 wei -> FAILURE 12 | // (): hex"00" -> FAILURE 13 | // (), 1 ether: hex"00" -> FAILURE 14 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/receive/ether_and_data.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | receive () payable external { } 3 | } 4 | // ---- 5 | // (), 1 ether 6 | // (), 1 ether: 1 -> FAILURE 7 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/receive/inherited.sol: -------------------------------------------------------------------------------- 1 | contract A { 2 | uint data; 3 | receive() external payable { ++data; } 4 | function getData() public returns (uint r) { return data; } 5 | } 6 | contract B is A {} 7 | // ---- 8 | // getData() -> 0 9 | // () -> 10 | // getData() -> 1 11 | // (), 1 ether -> 12 | // getData() -> 2 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/revertStrings/bubble.sol: -------------------------------------------------------------------------------- 1 | contract A { 2 | function g() public { revert("fail"); } 3 | } 4 | 5 | contract C { 6 | A a = new A(); 7 | function f() public { 8 | a.g(); 9 | } 10 | } 11 | // ==== 12 | // EVMVersion: >=byzantium 13 | // revertStrings: debug 14 | // ---- 15 | // f() -> FAILURE, hex"08c379a0", 0x20, 4, "fail" 16 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/revertStrings/calldata_array_dynamic_invalid.sol: -------------------------------------------------------------------------------- 1 | pragma abicoder v2; 2 | contract C { 3 | function f(uint256[][] calldata a) external returns (uint) { 4 | return 42; 5 | } 6 | } 7 | // ==== 8 | // EVMVersion: >=byzantium 9 | // revertStrings: debug 10 | // ---- 11 | // f(uint256[][]): 0x20, 1 -> FAILURE, hex"08c379a0", 0x20, 43, "ABI decoding: invalid calldata a", "rray stride" 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/revertStrings/calldata_tail_short.sol: -------------------------------------------------------------------------------- 1 | pragma abicoder v2; 2 | contract C { 3 | function f(uint256[][] calldata x) external { x[0]; } 4 | } 5 | // ==== 6 | // EVMVersion: >=byzantium 7 | // revertStrings: debug 8 | // ---- 9 | // f(uint256[][]): 0x20, 1, 0x20, 2, 0x42 -> FAILURE, hex"08c379a0", 0x20, 23, "Calldata tail too short" 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/revertStrings/enum_v1.sol: -------------------------------------------------------------------------------- 1 | pragma abicoder v1; 2 | contract C { 3 | enum E {X, Y} 4 | function f(E[] calldata arr) external { 5 | arr[1]; 6 | } 7 | } 8 | // ==== 9 | // EVMVersion: >=byzantium 10 | // revertStrings: debug 11 | // ABIEncoderV1Only: true 12 | // compileViaYul: false 13 | // ---- 14 | // f(uint8[]): 0x20, 2, 3, 3 -> FAILURE, hex"08c379a0", 0x20, 17, "Enum out of range" 15 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/revertStrings/enum_v2.sol: -------------------------------------------------------------------------------- 1 | pragma abicoder v2; 2 | contract C { 3 | enum E {X, Y} 4 | function f(E[] calldata arr) external { 5 | arr[1]; 6 | } 7 | } 8 | // ==== 9 | // EVMVersion: >=byzantium 10 | // revertStrings: debug 11 | // ---- 12 | // f(uint8[]): 0x20, 2, 3, 3 -> FAILURE 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/revertStrings/ether_non_payable_function.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public {} 3 | } 4 | // ==== 5 | // EVMVersion: >=byzantium 6 | // revertStrings: debug 7 | // ---- 8 | // f(), 1 ether -> FAILURE, hex"08c379a0", 0x20, 34, "Ether sent to non-payable functi", "on" 9 | // () -> FAILURE, hex"08c379a0", 0x20, 53, "Contract does not have fallback ", "nor receive functions" 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/revertStrings/function_entry_checks_v1.sol: -------------------------------------------------------------------------------- 1 | pragma abicoder v1; 2 | contract C { 3 | function t(uint) public pure {} 4 | } 5 | // ==== 6 | // EVMVersion: >=byzantium 7 | // ABIEncoderV1Only: true 8 | // revertStrings: debug 9 | // compileViaYul: false 10 | // ---- 11 | // t(uint256) -> FAILURE, hex"08c379a0", 0x20, 0x12, "Calldata too short" 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/revertStrings/function_entry_checks_v2.sol: -------------------------------------------------------------------------------- 1 | pragma abicoder v2; 2 | contract C { 3 | function t(uint) public pure {} 4 | } 5 | // ==== 6 | // EVMVersion: >=byzantium 7 | // revertStrings: debug 8 | // ---- 9 | // t(uint256) -> FAILURE, hex"08c379a0", 0x20, 34, "ABI decoding: tuple data too sho", "rt" 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/revertStrings/short_input_array.sol: -------------------------------------------------------------------------------- 1 | pragma abicoder v2; 2 | contract C { 3 | function f(uint[] memory a) public pure returns (uint) { return 7; } 4 | } 5 | // ==== 6 | // EVMVersion: >=byzantium 7 | // revertStrings: debug 8 | // ---- 9 | // f(uint256[]): 0x20, 1 -> FAILURE, hex"08c379a0", 0x20, 43, "ABI decoding: invalid calldata a", "rray stride" 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/revertStrings/short_input_bytes.sol: -------------------------------------------------------------------------------- 1 | pragma abicoder v2; 2 | contract C { 3 | function e(bytes memory a) public pure returns (uint) { return 7; } 4 | } 5 | // ==== 6 | // EVMVersion: >=byzantium 7 | // revertStrings: debug 8 | // ---- 9 | // e(bytes): 0x20, 7 -> FAILURE, hex"08c379a0", 0x20, 39, "ABI decoding: invalid byte array", " length" 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/revertStrings/unknown_sig_no_fallback.sol: -------------------------------------------------------------------------------- 1 | contract A { 2 | receive () external payable {} 3 | } 4 | // ==== 5 | // EVMVersion: >=byzantium 6 | // revertStrings: debug 7 | // ---- 8 | // (): hex"00" -> FAILURE, hex"08c379a0", 0x20, 41, "Unknown signature and no fallbac", "k defined" 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/reverts/error_struct.sol: -------------------------------------------------------------------------------- 1 | struct error { uint error; } 2 | contract C { 3 | error test(); 4 | error _struct; 5 | function f() public { 6 | revert test(); 7 | } 8 | function g(uint x) public returns (uint) { 9 | _struct.error = x; 10 | return _struct.error; 11 | } 12 | } 13 | // ---- 14 | // f() -> FAILURE, hex"f8a8fd6d" 15 | // g(uint256): 7 -> 7 16 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/reverts/invalid_instruction.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public { 3 | assembly { 4 | invalid() 5 | } 6 | } 7 | } 8 | // ---- 9 | // f() -> FAILURE 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/reverts/revert.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | uint256 public a = 42; 3 | 4 | function f() public { 5 | a = 1; 6 | revert(); 7 | } 8 | 9 | function g() public { 10 | a = 1; 11 | assembly { 12 | revert(0, 0) 13 | } 14 | } 15 | } 16 | // ---- 17 | // f() -> FAILURE 18 | // a() -> 42 19 | // g() -> FAILURE 20 | // a() -> 42 21 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/reverts/simple_throw.sol: -------------------------------------------------------------------------------- 1 | contract Test { 2 | function f(uint256 x) public returns (uint256) { 3 | if (x > 10) return x + 10; 4 | else revert(); 5 | return 2; 6 | } 7 | } 8 | // ---- 9 | // f(uint256): 11 -> 21 10 | // f(uint256): 1 -> FAILURE 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/shanghai/push0.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function zero() external returns (uint) { 3 | return 0; 4 | } 5 | 6 | } 7 | // ==== 8 | // compileViaYul: also 9 | // EVMVersion: >=shanghai 10 | // ---- 11 | // zero() -> 0 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/smoke/multiline.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(uint a, uint b, uint c, uint d, uint e) public returns (uint) { 3 | return a + b + c + d + e; 4 | } 5 | } 6 | // ==== 7 | // allowNonExistingFunctions: true 8 | // ---- 9 | // f(uint256,uint256,uint256,uint256,uint256): 1, 1, 1, 1, 1 10 | // -> 5 11 | // g() 12 | // # g() does not exist # 13 | // -> FAILURE 14 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/specialFunctions/abi_functions_member_access.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public pure { 3 | abi.encode; 4 | abi.encodePacked; 5 | abi.encodeWithSelector; 6 | abi.encodeWithSignature; 7 | abi.decode; 8 | } 9 | } 10 | // ---- 11 | // f() -> 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/state/block_basefee.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public view returns (uint) { 3 | return block.basefee; 4 | } 5 | function g() public view returns (uint ret) { 6 | assembly { 7 | ret := basefee() 8 | } 9 | } 10 | } 11 | // ==== 12 | // EVMVersion: >=london 13 | // ---- 14 | // f() -> 7 15 | // g() -> 7 16 | // f() -> 7 17 | // g() -> 7 18 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/state/block_chainid.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public returns (uint) { 3 | return block.chainid; 4 | } 5 | } 6 | // ==== 7 | // EVMVersion: >=istanbul 8 | // ---- 9 | // f() -> 1 10 | // f() -> 1 11 | // f() -> 1 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/state/block_coinbase.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public returns (address payable) { 3 | return block.coinbase; 4 | } 5 | } 6 | // ---- 7 | // f() -> 0x7878787878787878787878787878787878787878 8 | // f() -> 0x7878787878787878787878787878787878787878 9 | // f() -> 0x7878787878787878787878787878787878787878 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/state/block_difficulty.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public returns (uint) { 3 | return block.difficulty; 4 | } 5 | } 6 | // ==== 7 | // EVMVersion: 200000000 10 | // f() -> 200000000 11 | // f() -> 200000000 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/state/block_gaslimit.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public returns (uint) { 3 | return block.gaslimit; 4 | } 5 | } 6 | // ---- 7 | // f() -> 20000000 8 | // f() -> 20000000 9 | // f() -> 20000000 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/state/block_number.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | constructor() {} 3 | function f() public returns (uint) { 4 | return block.number; 5 | } 6 | } 7 | // ---- 8 | // constructor() 9 | // f() -> 2 10 | // f() -> 3 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/state/block_prevrandao.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public view returns (uint) { 3 | return block.prevrandao; 4 | } 5 | } 6 | // ==== 7 | // EVMVersion: >=paris 8 | // ---- 9 | // f() -> 0xa86c2e601b6c44eb4848f7d23d9df3113fbcac42041c49cbed5000cb4f118777 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/state/block_prevrandao_pre_paris.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public view returns (uint) { 3 | return block.prevrandao; 4 | } 5 | } 6 | // ==== 7 | // EVMVersion: 200000000 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/state/block_timestamp.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | constructor() {} 3 | function f() public returns (uint) { 4 | return block.timestamp; 5 | } 6 | } 7 | // ---- 8 | // constructor() # This is the 1st block # 9 | // f() -> 0x1e # This is the 2nd block (each block is "15 seconds") # 10 | // f() -> 0x2d # This is the 3rd block # 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/state/gasleft.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public returns (bool) { 3 | return gasleft() > 0; 4 | } 5 | } 6 | // ---- 7 | // f() -> true 8 | // f() -> true 9 | // f() -> true 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/state/msg_sender.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public returns (address) { 3 | return msg.sender; 4 | } 5 | } 6 | // ---- 7 | // f() -> 0x1212121212121212121212121212120000000012 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/state/msg_sig.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public returns (bytes4) { 3 | return msg.sig; 4 | } 5 | function g() public returns (bytes4) { 6 | return msg.sig; 7 | } 8 | } 9 | // ---- 10 | // f() -> 0x26121ff000000000000000000000000000000000000000000000000000000000 11 | // g() -> 0xe2179b8e00000000000000000000000000000000000000000000000000000000 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/state/msg_value.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public payable returns (uint) { 3 | return msg.value; 4 | } 5 | } 6 | // ---- 7 | // f() -> 0 8 | // f(), 12 ether -> 12000000000000000000 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/state/tx_gasprice.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public returns (uint) { 3 | return tx.gasprice; 4 | } 5 | } 6 | // ---- 7 | // f() -> 3000000000 8 | // f() -> 3000000000 9 | // f() -> 3000000000 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/state/tx_origin.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public returns (address) { 3 | return tx.origin; 4 | } 5 | } 6 | // ---- 7 | // f() -> 0x9292929292929292929292929292929292929292 8 | // f() -> 0x9292929292929292929292929292929292929292 9 | // f() -> 0x9292929292929292929292929292929292929292 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/state/uncalled_blockhash.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public returns (bytes32) { 3 | return (blockhash)(block.number - 1); 4 | } 5 | } 6 | // ---- 7 | // f() -> 0x3737373737373737373737373737373737373737373737373737373737373738 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/state_var_initialization.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | uint public i = 1; 3 | uint public k = 2; 4 | 5 | constructor() { 6 | i = i + i; 7 | k = k - i; 8 | } 9 | } 10 | // ---- 11 | // i() -> 2 12 | // k() -> 0 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/state_variables_init_order.sol: -------------------------------------------------------------------------------- 1 | contract A { 2 | uint public x = 0; 3 | uint y = f(); 4 | function f() public returns (uint256) { 5 | ++x; 6 | return 42; 7 | } 8 | } 9 | contract B is A { 10 | } 11 | // ---- 12 | // x() -> 1 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/state_variables_init_order_2.sol: -------------------------------------------------------------------------------- 1 | contract A { 2 | uint public x = 0; 3 | uint y = f(); 4 | function f() public returns (uint256) { 5 | ++x; 6 | return 42; 7 | } 8 | } 9 | contract B is A { 10 | uint public z; 11 | constructor() { 12 | z = x; 13 | } 14 | } 15 | // ---- 16 | // z() -> 1 17 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/statements/do_while_loop_continue.sol: -------------------------------------------------------------------------------- 1 | contract test { 2 | function f() public pure returns(uint r) { 3 | uint i = 0; 4 | do 5 | { 6 | if (i > 0) return 0; 7 | i++; 8 | continue; 9 | } while (false); 10 | return 42; 11 | } 12 | } 13 | // ---- 14 | // f() -> 42 15 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/storage/simple_accessor.sol: -------------------------------------------------------------------------------- 1 | contract test { 2 | uint256 public data; 3 | constructor() { 4 | data = 8; 5 | } 6 | } 7 | // ---- 8 | // data() -> 8 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/storage/struct_accessor.sol: -------------------------------------------------------------------------------- 1 | contract test { 2 | struct Data { uint a; uint8 b; mapping(uint => uint) c; bool d; } 3 | mapping(uint => Data) public data; 4 | constructor() { 5 | data[7].a = 1; 6 | data[7].b = 2; 7 | data[7].c[0] = 3; 8 | data[7].d = true; 9 | } 10 | } 11 | // ---- 12 | // data(uint256): 7 -> 1, 2, true 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/strings/concat/string_concat_empty_argument_list.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public returns (string memory) { 3 | return string.concat(); 4 | } 5 | } 6 | // ---- 7 | // f() -> 0x20, 0 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/strings/concat/string_concat_nested.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(string memory a, string memory b, string memory c) public returns (string memory) { 3 | return string.concat(string.concat(a, b), c); 4 | } 5 | } 6 | // ---- 7 | // f(string,string,string): 0x60, 0x60, 0x60, 2, "ab" -> 0x20, 6, "ababab" 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/strings/empty_string.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public pure returns (string memory) { 3 | return ""; 4 | } 5 | } 6 | // ---- 7 | // f() -> 0x20, 0 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/strings/string_escapes.sol: -------------------------------------------------------------------------------- 1 | contract test { 2 | function f() public pure returns (bytes32) { 3 | bytes32 escapeCharacters = "\t\n\r\'\"\\"; 4 | return escapeCharacters; 5 | } 6 | } 7 | // ---- 8 | // f() -> 0x090a0d27225c0000000000000000000000000000000000000000000000000000 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/structs/array_of_recursive_struct.sol: -------------------------------------------------------------------------------- 1 | contract Test { 2 | struct RecursiveStruct { 3 | RecursiveStruct[] vals; 4 | } 5 | 6 | function func() public pure { 7 | RecursiveStruct[1] memory val = [ RecursiveStruct(new RecursiveStruct[](42)) ]; 8 | assert(val[0].vals.length == 42); 9 | } 10 | } 11 | // ---- 12 | // func() -> 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/structs/calldata/calldata_struct.sol: -------------------------------------------------------------------------------- 1 | pragma abicoder v2; 2 | 3 | 4 | contract C { 5 | struct S { 6 | uint256 a; 7 | uint256 b; 8 | } 9 | 10 | function f(S calldata s) external pure returns (uint256 a, uint256 b) { 11 | a = s.a; 12 | b = s.b; 13 | } 14 | } 15 | // ---- 16 | // f((uint256,uint256)): 42, 23 -> 42, 23 17 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/structs/calldata/dynamically_encoded.sol: -------------------------------------------------------------------------------- 1 | pragma abicoder v2; 2 | 3 | contract C { 4 | struct S { uint256[] a; } 5 | function f(S calldata s) external pure returns (uint256 a, uint256 b, uint256 c) { 6 | return (s.a.length, s.a[0], s.a[1]); 7 | } 8 | } 9 | // ---- 10 | // f((uint256[])): 32, 32, 2, 42, 23 -> 2, 42, 23 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/structs/event.sol: -------------------------------------------------------------------------------- 1 | pragma abicoder v2; 2 | 3 | struct Item {uint x;} 4 | library L { 5 | event Ev(Item); 6 | function o() public { emit L.Ev(Item(1)); } 7 | } 8 | contract C { 9 | function f() public { 10 | L.o(); 11 | } 12 | } 13 | // ---- 14 | // library: L 15 | // f() -> 16 | // ~ emit Ev((uint256)): 0x01 17 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/structs/global.sol: -------------------------------------------------------------------------------- 1 | pragma abicoder v2; 2 | 3 | struct S { uint256 a; uint256 b; } 4 | contract C { 5 | function f(S calldata s) external pure returns (uint256, uint256) { 6 | return (s.a, s.b); 7 | } 8 | } 9 | // ---- 10 | // f((uint256,uint256)): 42, 23 -> 42, 23 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/structs/lone_struct_array_type.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | struct s { 3 | uint256 a; 4 | uint256 b; 5 | } 6 | 7 | function f() public returns (uint256) { 8 | s[7][]; // This is only the type, should not have any effect 9 | return 3; 10 | } 11 | } 12 | // ---- 13 | // f() -> 3 14 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/structs/memory_struct_named_constructor.sol: -------------------------------------------------------------------------------- 1 | pragma abicoder v2; 2 | 3 | contract C { 4 | struct S { 5 | uint256 a; 6 | bool x; 7 | } 8 | 9 | function s() public returns(S memory) 10 | { 11 | return S({x: true, a: 8}); 12 | } 13 | } 14 | // ---- 15 | // s() -> 8, true 16 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/structs/nested_struct_allocation.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | struct I { 3 | uint b; 4 | uint c; 5 | } 6 | struct S { 7 | I a; 8 | } 9 | 10 | function f() external returns (uint) { 11 | S memory s = S(I(1,2)); 12 | return s.a.b; 13 | } 14 | } 15 | // ---- 16 | // f() -> 1 17 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/structs/simple_struct_allocation.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | struct S { 3 | uint a; 4 | } 5 | 6 | function f() external returns (uint) { 7 | S memory s = S(1); 8 | return s.a; 9 | } 10 | } 11 | // ---- 12 | // f() -> 1 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/structs/struct_named_constructor.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | struct S { 3 | uint256 a; 4 | bool x; 5 | } 6 | S public s; 7 | 8 | constructor() { 9 | s = S({x: true, a: 1}); 10 | } 11 | } 12 | // ---- 13 | // s() -> 1, true 14 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/structs/struct_storage_to_mapping.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | struct S { 3 | uint a; 4 | } 5 | S s; 6 | mapping (uint => S) m; 7 | 8 | function f() external returns (bool) { 9 | s.a = 12; 10 | m[1] = s; 11 | return m[1].a == 12; 12 | } 13 | } 14 | // ---- 15 | // f() -> true 16 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/types/assign_calldata_value_type.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(uint256 x) public pure returns (uint256, uint256) { 3 | uint256 b = x; 4 | x = 42; 5 | return (x, b); 6 | } 7 | } 8 | // ---- 9 | // f(uint256): 23 -> 42, 23 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/types/convert_fixed_bytes_to_fixed_bytes_greater_size.sol: -------------------------------------------------------------------------------- 1 | contract Test { 2 | function bytesToBytes(bytes2 input) public returns (bytes4 ret) { 3 | return bytes4(input); 4 | } 5 | } 6 | // ---- 7 | // bytesToBytes(bytes2): "ab" -> "ab" 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/types/convert_fixed_bytes_to_fixed_bytes_same_size.sol: -------------------------------------------------------------------------------- 1 | contract Test { 2 | function bytesToBytes(bytes4 input) public returns (bytes4 ret) { 3 | return bytes4(input); 4 | } 5 | } 6 | // ---- 7 | // bytesToBytes(bytes4): "abcd" -> "abcd" 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/types/convert_fixed_bytes_to_fixed_bytes_smaller_size.sol: -------------------------------------------------------------------------------- 1 | contract Test { 2 | function bytesToBytes(bytes4 input) public returns (bytes2 ret) { 3 | return bytes2(input); 4 | } 5 | } 6 | // ---- 7 | // bytesToBytes(bytes4): "abcd" -> "ab" 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/types/convert_fixed_bytes_to_uint_greater_size.sol: -------------------------------------------------------------------------------- 1 | contract Test { 2 | function bytesToUint(bytes4 s) public returns (uint64 h) { 3 | return uint64(uint32(s)); 4 | } 5 | } 6 | // ---- 7 | // bytesToUint(bytes4): "abcd" -> 0x61626364 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/types/convert_fixed_bytes_to_uint_same_min_size.sol: -------------------------------------------------------------------------------- 1 | contract Test { 2 | function bytesToUint(bytes1 s) public returns (uint8 h) { 3 | return uint8(s); 4 | } 5 | } 6 | // ---- 7 | // bytesToUint(bytes1): "a" -> 0x61 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/types/convert_fixed_bytes_to_uint_same_type.sol: -------------------------------------------------------------------------------- 1 | contract Test { 2 | function bytesToUint(bytes32 s) public returns (uint256 h) { 3 | return uint(s); 4 | } 5 | } 6 | // ---- 7 | // bytesToUint(bytes32): "abc2" -> left(0x61626332) 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/types/convert_fixed_bytes_to_uint_smaller_size.sol: -------------------------------------------------------------------------------- 1 | contract Test { 2 | function bytesToUint(bytes4 s) public returns (uint16 h) { 3 | return uint16(uint32(s)); 4 | } 5 | } 6 | // ---- 7 | // bytesToUint(bytes4): "abcd" -> 0x6364 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/types/convert_uint_to_fixed_bytes_greater_size.sol: -------------------------------------------------------------------------------- 1 | contract Test { 2 | function UintToBytes(uint16 h) public returns (bytes8 s) { 3 | return bytes8(uint64(h)); 4 | } 5 | } 6 | // ---- 7 | // UintToBytes(uint16): 0x6162 -> "\x00\x00\x00\x00\x00\x00ab" 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/types/convert_uint_to_fixed_bytes_same_min_size.sol: -------------------------------------------------------------------------------- 1 | contract Test { 2 | function UintToBytes(uint8 h) public returns (bytes1 s) { 3 | return bytes1(h); 4 | } 5 | } 6 | // ---- 7 | // UintToBytes(uint8): 0x61 -> "a" 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/types/convert_uint_to_fixed_bytes_same_size.sol: -------------------------------------------------------------------------------- 1 | contract Test { 2 | function uintToBytes(uint256 h) public returns (bytes32 s) { 3 | return bytes32(h); 4 | } 5 | } 6 | // ---- 7 | // uintToBytes(uint256): left(0x616263) -> left(0x616263) 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/types/convert_uint_to_fixed_bytes_smaller_size.sol: -------------------------------------------------------------------------------- 1 | contract Test { 2 | function uintToBytes(uint32 h) public returns (bytes2 s) { 3 | return bytes2(uint16(h)); 4 | } 5 | } 6 | // ---- 7 | // uintToBytes(uint32): 0x61626364 -> "cd" 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/types/mapping_abstract_constructor_param.sol: -------------------------------------------------------------------------------- 1 | abstract contract A { 2 | constructor (mapping (uint => uint) storage m) { 3 | m[5] = 20; 4 | } 5 | } 6 | 7 | contract C is A { 8 | mapping (uint => uint) public m; 9 | 10 | constructor() A(m) { 11 | } 12 | } 13 | // ---- 14 | // m(uint256): 1 -> 0 15 | // m(uint256): 5 -> 20 16 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/types/packing_signed_types.sol: -------------------------------------------------------------------------------- 1 | contract test { 2 | function run() public returns(int8 y) { 3 | uint8 x = 0xfa; 4 | return int8(x); 5 | } 6 | } 7 | // ---- 8 | // run() -> 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/types/tuple_assign_multi_slot_grow.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | 3 | function f() public pure returns (uint, uint, uint) { 4 | bytes memory a; bytes memory b; bytes memory c; 5 | (a, (b, c)) = ("0", ("1", "2")); 6 | return (uint8(a[0]), uint8(b[0]), uint8(c[0])); 7 | } 8 | 9 | } 10 | // ---- 11 | // f() -> 0x30, 0x31, 0x32 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/types/type_conversion_cleanup.sol: -------------------------------------------------------------------------------- 1 | contract Test { 2 | function test() public returns (uint ret) { return uint(uint160(address(uint160(uint128(type(uint200).max))))); } 3 | } 4 | // ---- 5 | // test() -> 0xffffffffffffffffffffffffffffffff 6 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/underscore/as_function.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function _() public pure returns (uint) { 3 | return 88; 4 | } 5 | 6 | function g() public pure returns (uint){ 7 | return _(); 8 | } 9 | 10 | function h() public pure returns (uint) { 11 | _; 12 | return 33; 13 | } 14 | } 15 | // ---- 16 | // _() -> 88 17 | // g() -> 88 18 | // h() -> 33 19 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/userDefinedValueType/in_parenthesis.sol: -------------------------------------------------------------------------------- 1 | type MyInt is int; 2 | contract C { 3 | function f() public returns (MyInt a, int b) { 4 | (MyInt).wrap; 5 | a = (MyInt).wrap(5); 6 | (MyInt).unwrap; 7 | b = (MyInt).unwrap((MyInt).wrap(10)); 8 | } 9 | } 10 | // ---- 11 | // f() -> 5, 10 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/userDefinedValueType/simple.sol: -------------------------------------------------------------------------------- 1 | type MyInt is int; 2 | contract C { 3 | function f() external pure returns (MyInt a) { 4 | } 5 | function g() external pure returns (MyInt b, MyInt c) { 6 | b = MyInt.wrap(int(1)); 7 | c = MyInt.wrap(1); 8 | } 9 | } 10 | // ---- 11 | // f() -> 0 12 | // g() -> 1, 1 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/userDefinedValueType/wrap_unwrap.sol: -------------------------------------------------------------------------------- 1 | type MyAddress is address; 2 | contract C { 3 | function f() pure public { 4 | MyAddress.wrap; 5 | MyAddress.unwrap; 6 | } 7 | } 8 | // ---- 9 | // f() -> 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/using/private_library_function.sol: -------------------------------------------------------------------------------- 1 | library L { 2 | using {L.privateFunction} for uint; 3 | function privateFunction(uint x) private pure returns (uint) { return x + 1; } 4 | function f() public pure returns (uint) { 5 | uint x = 1; 6 | return x.privateFunction(); 7 | } 8 | } 9 | // ---- 10 | // f() -> 2 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/variables/delete_local.sol: -------------------------------------------------------------------------------- 1 | contract test { 2 | function delLocal() public returns (uint res){ 3 | uint v = 5; 4 | delete v; 5 | res = v; 6 | } 7 | } 8 | // ---- 9 | // delLocal() -> 0 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/variables/delete_locals.sol: -------------------------------------------------------------------------------- 1 | contract test { 2 | function delLocal() public returns (uint res1, uint res2){ 3 | uint v = 5; 4 | uint w = 6; 5 | uint x = 7; 6 | delete v; 7 | res1 = w; 8 | res2 = x; 9 | } 10 | } 11 | // ---- 12 | // delLocal() -> 6, 7 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/variables/public_state_overridding.sol: -------------------------------------------------------------------------------- 1 | contract A 2 | { 3 | function test() external virtual returns (uint256) 4 | { 5 | return 5; 6 | } 7 | } 8 | contract X is A 9 | { 10 | uint256 public override test; 11 | 12 | function set() public { test = 2; } 13 | } 14 | // ---- 15 | // test() -> 0 16 | // set() -> 17 | // test() -> 2 18 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/various/assignment_to_const_var_involving_expression.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | uint256 constant x = 0x123 + 0x456; 3 | 4 | function f() public returns (uint256) { 5 | return x + 1; 6 | } 7 | } 8 | // ---- 9 | // f() -> 0x57a 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/various/balance.sol: -------------------------------------------------------------------------------- 1 | contract test { 2 | constructor() payable {} 3 | 4 | function getBalance() public returns (uint256 balance) { 5 | return address(this).balance; 6 | } 7 | } 8 | // ---- 9 | // constructor(), 23 wei -> 10 | // getBalance() -> 23 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/various/contract_binary_dependencies.sol: -------------------------------------------------------------------------------- 1 | contract A { 2 | function f() public { 3 | new B(); 4 | } 5 | } 6 | 7 | 8 | contract B { 9 | function f() public {} 10 | } 11 | 12 | 13 | contract C { 14 | function f() public { 15 | new B(); 16 | } 17 | } 18 | // ---- 19 | // constructor() -> 20 | // gas irOptimized: 100415 21 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/various/crazy_elementary_typenames_on_stack.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public returns (uint256 r) { 3 | uint256; 4 | uint256; 5 | uint256; 6 | uint256; 7 | int256 x = -7; 8 | return uint256(x); 9 | } 10 | } 11 | // ---- 12 | // f() -> -7 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/various/cross_contract_types.sol: -------------------------------------------------------------------------------- 1 | contract Lib { 2 | struct S { 3 | uint256 a; 4 | uint256 b; 5 | } 6 | } 7 | 8 | 9 | contract Test { 10 | function f() public returns (uint256 r) { 11 | Lib.S memory x = Lib.S({a: 2, b: 3}); 12 | r = x.b; 13 | } 14 | } 15 | // ---- 16 | // f() -> 3 17 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/various/decayed_tuple.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public returns (uint256) { 3 | uint256 x = 1; 4 | (x) = 2; 5 | return x; 6 | } 7 | } 8 | // ---- 9 | // f() -> 2 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/various/empty_name_return_parameter.sol: -------------------------------------------------------------------------------- 1 | contract test { 2 | function f(uint256 k) public returns (uint256) { 3 | return k; 4 | } 5 | } 6 | // ---- 7 | // f(uint256): 9 -> 9 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/various/flipping_sign_tests.sol: -------------------------------------------------------------------------------- 1 | contract test { 2 | function f() public returns (bool) { 3 | int256 x = -2**255; 4 | unchecked { assert(-x == x); } 5 | return true; 6 | } 7 | } 8 | // ---- 9 | // f() -> true 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/various/gasleft_shadow_resolution.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function gasleft() public returns (uint256) { 3 | return 0; 4 | } 5 | 6 | function f() public returns (uint256) { 7 | return gasleft(); 8 | } 9 | } 10 | // ---- 11 | // f() -> 0 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/various/inline_tuple_with_rational_numbers.sol: -------------------------------------------------------------------------------- 1 | contract c { 2 | function f() public returns (int8) { 3 | int8[5] memory foo3 = [int8(1), -1, 0, 0, 0]; 4 | return foo3[0]; 5 | } 6 | } 7 | // ---- 8 | // f() -> 1 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/various/literal_empty_string.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | bytes32 public x; 3 | uint256 public a; 4 | 5 | function f(bytes32 _x, uint256 _a) public { 6 | x = _x; 7 | a = _a; 8 | } 9 | 10 | function g() public { 11 | this.f("", 2); 12 | } 13 | } 14 | // ---- 15 | // x() -> 0 16 | // a() -> 0 17 | // g() -> 18 | // x() -> 0 19 | // a() -> 2 20 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/various/memory_overwrite.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public returns (bytes memory x) { 3 | x = "12345"; 4 | x[3] = 0x61; 5 | x[0] = 0x62; 6 | } 7 | } 8 | // ---- 9 | // f() -> 0x20, 5, "b23a5" 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/various/positive_integers_to_signed.sol: -------------------------------------------------------------------------------- 1 | contract test { 2 | int8 public x = 2; 3 | int8 public y = 127; 4 | int16 public q = 250; 5 | } 6 | // ---- 7 | // x() -> 2 8 | // y() -> 127 9 | // q() -> 250 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/various/state_variable_local_variable_mixture.sol: -------------------------------------------------------------------------------- 1 | contract A { 2 | uint256 x = 1; 3 | uint256 y = 2; 4 | 5 | function a() public returns (uint256 x) { 6 | x = A.y; 7 | } 8 | } 9 | // ---- 10 | // a() -> 2 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/various/state_variable_under_contract_name.sol: -------------------------------------------------------------------------------- 1 | contract Scope { 2 | uint256 stateVar = 42; 3 | 4 | function getStateVar() public view returns (uint256 stateVar) { 5 | stateVar = Scope.stateVar; 6 | } 7 | } 8 | // ---- 9 | // getStateVar() -> 42 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/various/storage_string_as_mapping_key_without_variable.sol: -------------------------------------------------------------------------------- 1 | contract Test { 2 | mapping(string => uint256) data; 3 | 4 | function f() public returns (uint256) { 5 | data["abc"] = 2; 6 | return data["abc"]; 7 | } 8 | } 9 | // ---- 10 | // f() -> 2 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/various/store_bytes.sol: -------------------------------------------------------------------------------- 1 | // this test just checks that the copy loop does not mess up the stack 2 | contract C { 3 | function save() public returns (uint256 r) { 4 | r = 23; 5 | savedData = msg.data; 6 | r = 24; 7 | } 8 | 9 | bytes savedData; 10 | } 11 | // ---- 12 | // save() -> 24 # empty copy loop # 13 | // save(): "abcdefg" -> 24 14 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/various/super_alone.sol: -------------------------------------------------------------------------------- 1 | contract A { 2 | function f() public { 3 | super; 4 | } 5 | } 6 | // ---- 7 | // f() -> 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/various/test_underscore_in_hex.sol: -------------------------------------------------------------------------------- 1 | contract test { 2 | function f(bool cond) public pure returns (uint256) { 3 | uint32 x = 0x1234_ab; 4 | uint256 y = 0x1234_abcd_1234; 5 | return cond ? x : y; 6 | } 7 | } 8 | // ---- 9 | // f(bool): true -> 0x1234ab 10 | // f(bool): false -> 0x1234abcd1234 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/viaYul/conditional/conditional_multiple.sol: -------------------------------------------------------------------------------- 1 | contract A { 2 | function f() public pure returns (uint) { 3 | uint x = 3 < 0 ? 2 > 1 ? 2 : 1 : 7 > 2 ? 7 : 6; 4 | return x; 5 | } 6 | } 7 | // ---- 8 | // f() -> 7 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/viaYul/conditional/conditional_true_false_literal.sol: -------------------------------------------------------------------------------- 1 | contract A { 2 | function f() public pure returns (uint) { 3 | uint x = true ? 1 : 0; 4 | uint y = false ? 0 : 1; 5 | return x + y; 6 | } 7 | } 8 | // ---- 9 | // f() -> 2 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/viaYul/conditional/conditional_tuple.sol: -------------------------------------------------------------------------------- 1 | contract A { 2 | function f(bool cond) public pure returns (uint, uint) { 3 | (uint a, uint b) = cond ? (1, 2) : (3, 4); 4 | return (a, b); 5 | } 6 | } 7 | // ---- 8 | // f(bool): true -> 1, 2 9 | // f(bool): false -> 3, 4 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/viaYul/conditional/conditional_with_assignment.sol: -------------------------------------------------------------------------------- 1 | contract A { 2 | function f() public pure returns (uint, uint, uint, uint) { 3 | uint y1 = 1; 4 | uint y2 = 1; 5 | uint x = 3 < 0 ? y1 = 3 : 6; 6 | uint z = 3 < 10 ? y2 = 5 : 6; 7 | return (x, y1, y2, z); 8 | } 9 | } 10 | // ---- 11 | // f() -> 6, 1, 5, 5 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/viaYul/conditional/conditional_with_variables.sol: -------------------------------------------------------------------------------- 1 | contract A { 2 | function f() public pure returns (uint, uint, uint, uint) { 3 | uint x = 3; 4 | uint y = 1; 5 | uint z = (x > y) ? x : y; 6 | uint w = x < y ? x : y; 7 | return (x, y, z, w); 8 | } 9 | } 10 | // ---- 11 | // f() -> 3, 1, 3, 1 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/viaYul/conversion/explicit_cast_assignment.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public pure returns (uint16 x) { 3 | uint8 y = uint8(0x78); 4 | x = y; 5 | } 6 | } 7 | // ---- 8 | // f() -> 0x78 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/viaYul/conversion/explicit_cast_function_call.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(bytes32 b) public pure returns (bytes32 x) { 3 | x = b; 4 | } 5 | function g() public pure returns (bytes32 x) { 6 | x = f(bytes4(uint32(0x12345678))); 7 | } 8 | } 9 | // ---- 10 | // g() -> 0x1234567800000000000000000000000000000000000000000000000000000000 11 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/viaYul/conversion/explicit_cast_local_assignment.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(uint a) public pure returns (uint8 x) { 3 | uint8 b = uint8(a); 4 | x = b; 5 | } 6 | } 7 | // ---- 8 | // f(uint256): 0x12345678 -> 0x78 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/viaYul/conversion/explicit_string_bytes_calldata_cast.sol: -------------------------------------------------------------------------------- 1 | // Triggered ICE before 2 | contract C { 3 | function f(string calldata data) external pure returns(string memory) { 4 | bytes calldata test = bytes(data[:3]); 5 | return string(test); 6 | } 7 | } 8 | // ---- 9 | // f(string): 0x20, 3, "123" -> 0x20, 3, "123" 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/viaYul/conversion/implicit_cast_assignment.sol: -------------------------------------------------------------------------------- 1 | // Tests IRGeneratorForStatements::visit(Assignment const& _assignment) 2 | contract C { 3 | function f() public pure returns (uint16 x) { 4 | uint8 y; 5 | assembly { 6 | y := 0x12345678 7 | } 8 | x = y; 9 | } 10 | } 11 | // ---- 12 | // f() -> 0x78 13 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/viaYul/conversion/implicit_cast_local_assignment.sol: -------------------------------------------------------------------------------- 1 | // IRGeneratorForStatements::visit(VariableDeclarationStatement const& _varDeclStatement) 2 | contract C { 3 | function f() public pure returns (uint y) { 4 | uint8 a; 5 | assembly { a := 0x12345678 } 6 | uint z = a; 7 | y = z; 8 | } 9 | } 10 | // ---- 11 | // f() -> 0x78 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/viaYul/empty_return_corrupted_free_memory_pointer.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public { 3 | assembly{ mstore(0x40, sub(0, 1)) } 4 | } 5 | } 6 | // ---- 7 | // f() -> 8 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/viaYul/function_selector.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() external returns (bytes4) { 3 | return this.f.selector; 4 | } 5 | function h(function() external a) public returns (bytes4) { 6 | return a.selector; 7 | } 8 | } 9 | // ---- 10 | // f() -> left(0x26121ff0) 11 | // h(function): left(0x1122334400112233445566778899AABBCCDDEEFF42424242) -> left(0x42424242) 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/viaYul/local_address_assignment.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(address a) public pure returns (address x) { 3 | address b = a; 4 | x = b; 5 | } 6 | } 7 | // ---- 8 | // f(address): 0x1234 -> 0x1234 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/viaYul/local_assignment.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(uint a) public pure returns (uint x) { 3 | uint b = a; 4 | x = b; 5 | } 6 | } 7 | // ---- 8 | // f(uint256): 6 -> 6 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/viaYul/local_bool_assignment.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(bool a) public pure returns (bool x) { 3 | bool b = a; 4 | x = b; 5 | } 6 | } 7 | // ---- 8 | // f(bool): true -> true 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/viaYul/local_variable_without_init.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public pure returns (uint) { 3 | uint x; 4 | return x; 5 | } 6 | } 7 | // ---- 8 | // f() -> 0 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/viaYul/mapping_string_key.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | mapping (string => uint) map; 3 | function set(string memory s) public { 4 | map[s]; 5 | } 6 | } 7 | // ---- 8 | // set(string): 0x20, 32, "01234567890123456789012345678901" -> 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/viaYul/msg_sender.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function test() public view returns (bool) { 3 | address x; 4 | assembly { x := caller() } 5 | return x == msg.sender; 6 | } 7 | } 8 | // ---- 9 | // test() -> true 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/viaYul/negation_bug.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public pure { 3 | -(int8(0)); 4 | unchecked { 5 | // Used to incorrectly use the checked unary negation function and revert. 6 | (-(type(int8).min)); 7 | } 8 | } 9 | } 10 | // ---- 11 | // f() -> 12 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/viaYul/return.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public pure returns (uint x) { 3 | return 7; 4 | x = 3; 5 | } 6 | } 7 | // ---- 8 | // f() -> 7 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/viaYul/return_and_convert.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public pure returns (uint) { 3 | uint8 b; 4 | assembly { b := 0xffff } 5 | return b; 6 | } 7 | } 8 | // ---- 9 | // f() -> 255 10 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/viaYul/return_storage_pointers.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | uint[] arr1; 3 | uint[][] arr2; 4 | function f() internal returns (uint[] storage ptr1, uint[][] storage ptr2) { 5 | ptr1 = arr1; 6 | ptr2 = arr2; 7 | } 8 | function g() public returns (uint, uint) { 9 | return (arr1.length, arr2.length); 10 | } 11 | 12 | } 13 | // ---- 14 | // g() -> 0, 0 15 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/viaYul/simple_assignment.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f(uint a, uint b) public pure returns (uint x, uint y) { 3 | x = a; 4 | y = b; 5 | } 6 | } 7 | // ---- 8 | // f(uint256,uint256): 5, 6 -> 5, 6 9 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/viaYul/simple_inline_asm.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | function f() public pure returns (uint32 x) { 3 | uint32 a; 4 | uint32 b; 5 | uint32 c; 6 | assembly { 7 | a := 1 8 | b := 2 9 | c := 3 10 | } 11 | x = a + b + c; 12 | } 13 | } 14 | // ---- 15 | // f() -> 6 16 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/viaYul/smoke_test.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | } 3 | // ==== 4 | // allowNonExistingFunctions: true 5 | // ---- 6 | // f() -> FAILURE 7 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/viaYul/storage/packed_storage.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | uint16 x; 3 | bytes1 y; 4 | uint16 z; 5 | function f(uint8 a) public returns (uint _x) { 6 | x = a; 7 | y = bytes1(uint8(x) + 1); 8 | z = uint8(y) + 1; 9 | x = z + 1; 10 | _x = x; 11 | } 12 | } 13 | // ---- 14 | // f(uint8): 6 -> 9 15 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/viaYul/storage/simple_storage.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | uint x; 3 | uint y; 4 | function setX(uint a) public returns (uint _x) { 5 | x = a; 6 | _x = x; 7 | } 8 | function setY(uint a) public returns (uint _y) { 9 | y = a; 10 | _y = y; 11 | } 12 | } 13 | // ---- 14 | // setX(uint256): 6 -> 6 15 | // setY(uint256): 2 -> 2 16 | -------------------------------------------------------------------------------- /testcases/libsolidity/semanticTests/viaYul/tuple_evaluation_order.sol: -------------------------------------------------------------------------------- 1 | contract C { 2 | uint256 x; 3 | uint256 y; 4 | function set(uint256 v) public returns (uint256) { x = v; return v; } 5 | function f() public returns (uint256, uint256) { 6 | (y, y, y) = (set(1), set(2), set(3)); 7 | assert(y == 1 && x == 3); 8 | return (x, y); 9 | } 10 | } 11 | // ---- 12 | // f() -> 3, 1 13 | -------------------------------------------------------------------------------- /testcases/type_tests/ErrorSelector.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.8.0; 2 | 3 | interface MyI { 4 | error MyE(); 5 | } 6 | 7 | contract B { 8 | function x() public returns (bytes4) { 9 | return MyI.MyE.selector; 10 | } 11 | } -------------------------------------------------------------------------------- /testcases/type_tests/float_type.sol: -------------------------------------------------------------------------------- 1 | pragma solidity ^0.8.0; 2 | 3 | contract float_type { 4 | constructor(){ 5 | uint256 x = 0.01 * 0.02 ether; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /testcases/type_tests/missing_member.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.0; 3 | 4 | contract missing_member { 5 | constructor(){ 6 | this.unknownField = 5; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /testcases/using_directives/ImportableUser.sol: -------------------------------------------------------------------------------- 1 | pragma solidity 0.8.22; 2 | 3 | struct User2 { 4 | string name; 5 | uint count; 6 | } 7 | 8 | function clear_count(User2 memory user) { 9 | user.count = 0; 10 | } 11 | 12 | // Now even when User is imported, the clear_count() method can be used. 13 | using {clear_count} for User2 global; -------------------------------------------------------------------------------- /testcases/using_directives/TestImportableUser.sol: -------------------------------------------------------------------------------- 1 | pragma solidity 0.8.22; 2 | 3 | import {User2} from "./ImportableUser.sol"; 4 | 5 | contract TestImportableUser { 6 | function testFoo(User2 memory user) public { 7 | user.clear_count(); 8 | } 9 | } -------------------------------------------------------------------------------- /testcases/weirdcases/empty_hex_literal.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: GPL-3.0 2 | 3 | pragma solidity >=0.8.2 <0.9.0; 4 | 5 | contract Test { 6 | function implicit() public pure returns (bytes memory) { 7 | bytes xs = bytes(hex""); 8 | return xs; 9 | } 10 | } -------------------------------------------------------------------------------- /vendor/antlr-4.11.1-complete.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zellic/solidity-parser/102cf4626f6be2a1cf86ef449ac2aa897ac3c2c8/vendor/antlr-4.11.1-complete.jar --------------------------------------------------------------------------------