diff --git a/src/ast/legacy/function_definition_processor.ts b/src/ast/legacy/function_definition_processor.ts index 9bb5bf5d..d3a55c8f 100644 --- a/src/ast/legacy/function_definition_processor.ts +++ b/src/ast/legacy/function_definition_processor.ts @@ -1,12 +1,13 @@ import { ASTNode } from "../ast_node"; import { ASTReader, ASTReaderConfiguration } from "../ast_reader"; -import { FunctionKind, FunctionStateMutability, FunctionVisibility } from "../constants"; +import { FunctionStateMutability, FunctionVisibility } from "../constants"; import { FunctionDefinition } from "../implementation/declaration/function_definition"; import { ModifierInvocation } from "../implementation/meta/modifier_invocation"; import { OverrideSpecifier } from "../implementation/meta/override_specifier"; import { ParameterList } from "../implementation/meta/parameter_list"; import { StructuredDocumentation } from "../implementation/meta/structured_documentation"; import { Block } from "../implementation/statement/block"; +import { detectFunctionKind } from "../utils"; import { LegacyNodeProcessor } from "./node_processor"; export class LegacyFunctionDefinitionProcessor extends LegacyNodeProcessor { @@ -24,7 +25,7 @@ export class LegacyFunctionDefinitionProcessor extends LegacyNodeProcessor { @@ -17,7 +18,7 @@ export class ModernFunctionDefinitionProcessor extends ModernNodeProcessor]> = [ ] ] ], + [ + "./test/samples/solidity/issue_132_fun_kind.sol", + [ + [CompilerKind.WASM, "./test/samples/solidity/issue_132_fun_kind.nodes.wasm.txt"], + [CompilerKind.Native, "./test/samples/solidity/issue_132_fun_kind.nodes.native.txt"] + ] + ], [ "./test/samples/solidity/latest_08.sol", [ diff --git a/test/samples/solidity/issue_132_fun_kind.nodes.native.txt b/test/samples/solidity/issue_132_fun_kind.nodes.native.txt new file mode 100644 index 00000000..bed8dc44 --- /dev/null +++ b/test/samples/solidity/issue_132_fun_kind.nodes.native.txt @@ -0,0 +1,577 @@ +SourceUnit #56 + id: 56 + src: "0:0:0" + sourceEntryKey: "./test/samples/solidity/issue_132_fun_kind.sol" + sourceListIndex: 0 + absolutePath: "./test/samples/solidity/issue_132_fun_kind.sol" + exportedSymbols: Map(1) { "FBNoArgs" -> 55 } + context: ASTContext #1000 + vPragmaDirectives: Array(1) [ PragmaDirective #29 ] + vImportDirectives: Array(0) + vContracts: Array(1) [ ContractDefinition #55 ] + vEnums: Array(0) + vErrors: Array(0) + vStructs: Array(0) + vFunctions: Array(0) + vVariables: Array(0) + vUserDefinedValueTypes: Array(0) + vUsingForDirectives: Array(0) + vExportedSymbols: Map(1) { "FBNoArgs" -> ContractDefinition #55 } + children: Array(2) [ PragmaDirective #29, ContractDefinition #55 ] + type: "SourceUnit" + firstChild: PragmaDirective #29 + lastChild: ContractDefinition #55 + previousSibling: undefined + nextSibling: undefined + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + PragmaDirective #29 + id: 29 + src: "0:0:0" + literals: Array(3) [ "solidity", "0.4", ".24" ] + context: ASTContext #1000 + parent: SourceUnit #56 + vIdentifier: "solidity" + vValue: "0.4.24" + type: "PragmaDirective" + children: Array(0) + firstChild: undefined + lastChild: undefined + previousSibling: undefined + nextSibling: ContractDefinition #55 + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + ContractDefinition #55 + id: 55 + src: "0:0:0" + name: "FBNoArgs" + scope: 56 + kind: "contract" + abstract: false + fullyImplemented: true + linearizedBaseContracts: Array(1) [ 55 ] + usedErrors: Array(0) + docString: undefined + nameLocation: undefined + context: ASTContext #1000 + parent: SourceUnit #56 + documentation: undefined + danglingDocumentation: undefined + vScope: SourceUnit #56 + vLinearizedBaseContracts: Array(1) [ ContractDefinition #55 ] + vUsedErrors: Array(0) + vInheritanceSpecifiers: Array(0) + vStateVariables: Array(1) [ VariableDeclaration #32 ] + vModifiers: Array(0) + vEvents: Array(0) + vErrors: Array(0) + vFunctions: Array(2) [ FunctionDefinition #40, FunctionDefinition #54 ] + vUsingForDirectives: Array(0) + vStructs: Array(0) + vEnums: Array(0) + vUserDefinedValueTypes: Array(0) + vConstructor: undefined + children: Array(3) [ VariableDeclaration #32, FunctionDefinition #40, FunctionDefinition #54 ] + type: "ContractDefinition" + firstChild: VariableDeclaration #32 + lastChild: FunctionDefinition #54 + previousSibling: PragmaDirective #29 + nextSibling: undefined + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + VariableDeclaration #32 + id: 32 + src: "0:0:0" + constant: false + indexed: false + name: "lastCall" + scope: 55 + stateVariable: true + storageLocation: "default" + visibility: "public" + mutability: "mutable" + typeString: "int8" + documentation: undefined + nameLocation: undefined + vType: ElementaryTypeName #30 + vOverrideSpecifier: undefined + vValue: Literal #31 + context: ASTContext #1000 + parent: ContractDefinition #55 + children: Array(2) [ ElementaryTypeName #30, Literal #31 ] + vScope: ContractDefinition #55 + type: "VariableDeclaration" + firstChild: ElementaryTypeName #30 + lastChild: Literal #31 + previousSibling: undefined + nextSibling: FunctionDefinition #40 + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + ElementaryTypeName #30 + id: 30 + src: "0:0:0" + typeString: "int8" + name: "int8" + stateMutability: "nonpayable" + context: ASTContext #1000 + parent: VariableDeclaration #32 + type: "ElementaryTypeName" + children: Array(0) + firstChild: undefined + lastChild: undefined + previousSibling: undefined + nextSibling: Literal #31 + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + Literal #31 + id: 31 + src: "0:0:0" + typeString: "int_const 0" + kind: "number" + hexValue: "30" + value: "0" + subdenomination: undefined + context: ASTContext #1000 + parent: VariableDeclaration #32 + type: "Literal" + children: Array(0) + firstChild: undefined + lastChild: undefined + previousSibling: ElementaryTypeName #30 + nextSibling: undefined + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + FunctionDefinition #40 + id: 40 + src: "0:0:0" + implemented: true + virtual: false + scope: 55 + kind: "fallback" + name: "" + visibility: "external" + stateMutability: "payable" + isConstructor: false + documentation: undefined + nameLocation: undefined + vParameters: ParameterList #33 + vReturnParameters: ParameterList #34 + vModifiers: Array(0) + vOverrideSpecifier: undefined + vBody: Block #39 + context: ASTContext #1000 + parent: ContractDefinition #55 + children: Array(3) [ ParameterList #33, ParameterList #34, Block #39 ] + vScope: ContractDefinition #55 + type: "FunctionDefinition" + firstChild: ParameterList #33 + lastChild: Block #39 + previousSibling: VariableDeclaration #32 + nextSibling: FunctionDefinition #54 + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + ParameterList #33 + id: 33 + src: "0:0:0" + context: ASTContext #1000 + parent: FunctionDefinition #40 + vParameters: Array(0) + children: Array(0) + type: "ParameterList" + firstChild: undefined + lastChild: undefined + previousSibling: undefined + nextSibling: ParameterList #34 + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + ParameterList #34 + id: 34 + src: "0:0:0" + context: ASTContext #1000 + parent: FunctionDefinition #40 + vParameters: Array(0) + children: Array(0) + type: "ParameterList" + firstChild: undefined + lastChild: undefined + previousSibling: ParameterList #33 + nextSibling: Block #39 + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + Block #39 + id: 39 + src: "0:0:0" + docString: undefined + context: ASTContext #1000 + parent: FunctionDefinition #40 + vStatements: Array(1) [ ExpressionStatement #38 ] + documentation: undefined + danglingDocumentation: undefined + children: Array(1) [ ExpressionStatement #38 ] + type: "Block" + firstChild: ExpressionStatement #38 + lastChild: ExpressionStatement #38 + previousSibling: ParameterList #34 + nextSibling: undefined + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + ExpressionStatement #38 + id: 38 + src: "0:0:0" + documentation: undefined + vExpression: Assignment #37 + context: ASTContext #1000 + parent: Block #39 + children: Array(1) [ Assignment #37 ] + type: "ExpressionStatement" + firstChild: Assignment #37 + lastChild: Assignment #37 + previousSibling: undefined + nextSibling: undefined + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + Assignment #37 + id: 37 + src: "0:0:0" + typeString: "int8" + operator: "=" + vLeftHandSide: Identifier #35 + vRightHandSide: Literal #36 + context: ASTContext #1000 + parent: ExpressionStatement #38 + children: Array(2) [ Identifier #35, Literal #36 ] + type: "Assignment" + firstChild: Identifier #35 + lastChild: Literal #36 + previousSibling: undefined + nextSibling: undefined + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + Identifier #35 + id: 35 + src: "0:0:0" + typeString: "int8" + name: "lastCall" + referencedDeclaration: 32 + context: ASTContext #1000 + parent: Assignment #37 + vReferencedDeclaration: VariableDeclaration #32 + vIdentifierType: "userDefined" + type: "Identifier" + children: Array(0) + firstChild: undefined + lastChild: undefined + previousSibling: undefined + nextSibling: Literal #36 + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + Literal #36 + id: 36 + src: "0:0:0" + typeString: "int_const 1" + kind: "number" + hexValue: "31" + value: "1" + subdenomination: undefined + context: ASTContext #1000 + parent: Assignment #37 + type: "Literal" + children: Array(0) + firstChild: undefined + lastChild: undefined + previousSibling: Identifier #35 + nextSibling: undefined + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + FunctionDefinition #54 + id: 54 + src: "0:0:0" + implemented: true + virtual: false + scope: 55 + kind: "function" + name: "id" + visibility: "public" + stateMutability: "nonpayable" + isConstructor: false + documentation: undefined + nameLocation: undefined + vParameters: ParameterList #43 + vReturnParameters: ParameterList #46 + vModifiers: Array(0) + vOverrideSpecifier: undefined + vBody: Block #53 + context: ASTContext #1000 + parent: ContractDefinition #55 + children: Array(3) [ ParameterList #43, ParameterList #46, Block #53 ] + vScope: ContractDefinition #55 + type: "FunctionDefinition" + firstChild: ParameterList #43 + lastChild: Block #53 + previousSibling: FunctionDefinition #40 + nextSibling: undefined + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + ParameterList #43 + id: 43 + src: "0:0:0" + context: ASTContext #1000 + parent: FunctionDefinition #54 + vParameters: Array(1) [ VariableDeclaration #42 ] + children: Array(1) [ VariableDeclaration #42 ] + type: "ParameterList" + firstChild: VariableDeclaration #42 + lastChild: VariableDeclaration #42 + previousSibling: undefined + nextSibling: ParameterList #46 + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + VariableDeclaration #42 + id: 42 + src: "0:0:0" + constant: false + indexed: false + name: "x" + scope: 54 + stateVariable: false + storageLocation: "default" + visibility: "internal" + mutability: "mutable" + typeString: "uint256" + documentation: undefined + nameLocation: undefined + vType: ElementaryTypeName #41 + vOverrideSpecifier: undefined + vValue: undefined + context: ASTContext #1000 + parent: ParameterList #43 + children: Array(1) [ ElementaryTypeName #41 ] + vScope: FunctionDefinition #54 + type: "VariableDeclaration" + firstChild: ElementaryTypeName #41 + lastChild: ElementaryTypeName #41 + previousSibling: undefined + nextSibling: undefined + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + ElementaryTypeName #41 + id: 41 + src: "0:0:0" + typeString: "uint256" + name: "uint" + stateMutability: "nonpayable" + context: ASTContext #1000 + parent: VariableDeclaration #42 + type: "ElementaryTypeName" + children: Array(0) + firstChild: undefined + lastChild: undefined + previousSibling: undefined + nextSibling: undefined + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + ParameterList #46 + id: 46 + src: "0:0:0" + context: ASTContext #1000 + parent: FunctionDefinition #54 + vParameters: Array(1) [ VariableDeclaration #45 ] + children: Array(1) [ VariableDeclaration #45 ] + type: "ParameterList" + firstChild: VariableDeclaration #45 + lastChild: VariableDeclaration #45 + previousSibling: ParameterList #43 + nextSibling: Block #53 + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + VariableDeclaration #45 + id: 45 + src: "0:0:0" + constant: false + indexed: false + name: "" + scope: 54 + stateVariable: false + storageLocation: "default" + visibility: "internal" + mutability: "mutable" + typeString: "uint256" + documentation: undefined + nameLocation: undefined + vType: ElementaryTypeName #44 + vOverrideSpecifier: undefined + vValue: undefined + context: ASTContext #1000 + parent: ParameterList #46 + children: Array(1) [ ElementaryTypeName #44 ] + vScope: FunctionDefinition #54 + type: "VariableDeclaration" + firstChild: ElementaryTypeName #44 + lastChild: ElementaryTypeName #44 + previousSibling: undefined + nextSibling: undefined + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + ElementaryTypeName #44 + id: 44 + src: "0:0:0" + typeString: "uint256" + name: "uint" + stateMutability: "nonpayable" + context: ASTContext #1000 + parent: VariableDeclaration #45 + type: "ElementaryTypeName" + children: Array(0) + firstChild: undefined + lastChild: undefined + previousSibling: undefined + nextSibling: undefined + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + Block #53 + id: 53 + src: "0:0:0" + docString: undefined + context: ASTContext #1000 + parent: FunctionDefinition #54 + vStatements: Array(2) [ ExpressionStatement #50, Return #52 ] + documentation: undefined + danglingDocumentation: undefined + children: Array(2) [ ExpressionStatement #50, Return #52 ] + type: "Block" + firstChild: ExpressionStatement #50 + lastChild: Return #52 + previousSibling: ParameterList #46 + nextSibling: undefined + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + ExpressionStatement #50 + id: 50 + src: "0:0:0" + documentation: undefined + vExpression: Assignment #49 + context: ASTContext #1000 + parent: Block #53 + children: Array(1) [ Assignment #49 ] + type: "ExpressionStatement" + firstChild: Assignment #49 + lastChild: Assignment #49 + previousSibling: undefined + nextSibling: Return #52 + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + Assignment #49 + id: 49 + src: "0:0:0" + typeString: "int8" + operator: "=" + vLeftHandSide: Identifier #47 + vRightHandSide: Literal #48 + context: ASTContext #1000 + parent: ExpressionStatement #50 + children: Array(2) [ Identifier #47, Literal #48 ] + type: "Assignment" + firstChild: Identifier #47 + lastChild: Literal #48 + previousSibling: undefined + nextSibling: undefined + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + Identifier #47 + id: 47 + src: "0:0:0" + typeString: "int8" + name: "lastCall" + referencedDeclaration: 32 + context: ASTContext #1000 + parent: Assignment #49 + vReferencedDeclaration: VariableDeclaration #32 + vIdentifierType: "userDefined" + type: "Identifier" + children: Array(0) + firstChild: undefined + lastChild: undefined + previousSibling: undefined + nextSibling: Literal #48 + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + Literal #48 + id: 48 + src: "0:0:0" + typeString: "int_const 2" + kind: "number" + hexValue: "32" + value: "2" + subdenomination: undefined + context: ASTContext #1000 + parent: Assignment #49 + type: "Literal" + children: Array(0) + firstChild: undefined + lastChild: undefined + previousSibling: Identifier #47 + nextSibling: undefined + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + Return #52 + id: 52 + src: "0:0:0" + documentation: undefined + functionReturnParameters: 18 + vExpression: Identifier #51 + context: ASTContext #1000 + parent: Block #53 + children: Array(1) [ Identifier #51 ] + vFunctionReturnParameters: ParameterList #18 + type: "Return" + firstChild: Identifier #51 + lastChild: Identifier #51 + previousSibling: ExpressionStatement #50 + nextSibling: undefined + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + Identifier #51 + id: 51 + src: "0:0:0" + typeString: "uint256" + name: "x" + referencedDeclaration: 42 + context: ASTContext #1000 + parent: Return #52 + vReferencedDeclaration: VariableDeclaration #42 + vIdentifierType: "userDefined" + type: "Identifier" + children: Array(0) + firstChild: undefined + lastChild: undefined + previousSibling: undefined + nextSibling: undefined + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } diff --git a/test/samples/solidity/issue_132_fun_kind.nodes.wasm.txt b/test/samples/solidity/issue_132_fun_kind.nodes.wasm.txt new file mode 100644 index 00000000..bed8dc44 --- /dev/null +++ b/test/samples/solidity/issue_132_fun_kind.nodes.wasm.txt @@ -0,0 +1,577 @@ +SourceUnit #56 + id: 56 + src: "0:0:0" + sourceEntryKey: "./test/samples/solidity/issue_132_fun_kind.sol" + sourceListIndex: 0 + absolutePath: "./test/samples/solidity/issue_132_fun_kind.sol" + exportedSymbols: Map(1) { "FBNoArgs" -> 55 } + context: ASTContext #1000 + vPragmaDirectives: Array(1) [ PragmaDirective #29 ] + vImportDirectives: Array(0) + vContracts: Array(1) [ ContractDefinition #55 ] + vEnums: Array(0) + vErrors: Array(0) + vStructs: Array(0) + vFunctions: Array(0) + vVariables: Array(0) + vUserDefinedValueTypes: Array(0) + vUsingForDirectives: Array(0) + vExportedSymbols: Map(1) { "FBNoArgs" -> ContractDefinition #55 } + children: Array(2) [ PragmaDirective #29, ContractDefinition #55 ] + type: "SourceUnit" + firstChild: PragmaDirective #29 + lastChild: ContractDefinition #55 + previousSibling: undefined + nextSibling: undefined + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + PragmaDirective #29 + id: 29 + src: "0:0:0" + literals: Array(3) [ "solidity", "0.4", ".24" ] + context: ASTContext #1000 + parent: SourceUnit #56 + vIdentifier: "solidity" + vValue: "0.4.24" + type: "PragmaDirective" + children: Array(0) + firstChild: undefined + lastChild: undefined + previousSibling: undefined + nextSibling: ContractDefinition #55 + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + ContractDefinition #55 + id: 55 + src: "0:0:0" + name: "FBNoArgs" + scope: 56 + kind: "contract" + abstract: false + fullyImplemented: true + linearizedBaseContracts: Array(1) [ 55 ] + usedErrors: Array(0) + docString: undefined + nameLocation: undefined + context: ASTContext #1000 + parent: SourceUnit #56 + documentation: undefined + danglingDocumentation: undefined + vScope: SourceUnit #56 + vLinearizedBaseContracts: Array(1) [ ContractDefinition #55 ] + vUsedErrors: Array(0) + vInheritanceSpecifiers: Array(0) + vStateVariables: Array(1) [ VariableDeclaration #32 ] + vModifiers: Array(0) + vEvents: Array(0) + vErrors: Array(0) + vFunctions: Array(2) [ FunctionDefinition #40, FunctionDefinition #54 ] + vUsingForDirectives: Array(0) + vStructs: Array(0) + vEnums: Array(0) + vUserDefinedValueTypes: Array(0) + vConstructor: undefined + children: Array(3) [ VariableDeclaration #32, FunctionDefinition #40, FunctionDefinition #54 ] + type: "ContractDefinition" + firstChild: VariableDeclaration #32 + lastChild: FunctionDefinition #54 + previousSibling: PragmaDirective #29 + nextSibling: undefined + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + VariableDeclaration #32 + id: 32 + src: "0:0:0" + constant: false + indexed: false + name: "lastCall" + scope: 55 + stateVariable: true + storageLocation: "default" + visibility: "public" + mutability: "mutable" + typeString: "int8" + documentation: undefined + nameLocation: undefined + vType: ElementaryTypeName #30 + vOverrideSpecifier: undefined + vValue: Literal #31 + context: ASTContext #1000 + parent: ContractDefinition #55 + children: Array(2) [ ElementaryTypeName #30, Literal #31 ] + vScope: ContractDefinition #55 + type: "VariableDeclaration" + firstChild: ElementaryTypeName #30 + lastChild: Literal #31 + previousSibling: undefined + nextSibling: FunctionDefinition #40 + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + ElementaryTypeName #30 + id: 30 + src: "0:0:0" + typeString: "int8" + name: "int8" + stateMutability: "nonpayable" + context: ASTContext #1000 + parent: VariableDeclaration #32 + type: "ElementaryTypeName" + children: Array(0) + firstChild: undefined + lastChild: undefined + previousSibling: undefined + nextSibling: Literal #31 + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + Literal #31 + id: 31 + src: "0:0:0" + typeString: "int_const 0" + kind: "number" + hexValue: "30" + value: "0" + subdenomination: undefined + context: ASTContext #1000 + parent: VariableDeclaration #32 + type: "Literal" + children: Array(0) + firstChild: undefined + lastChild: undefined + previousSibling: ElementaryTypeName #30 + nextSibling: undefined + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + FunctionDefinition #40 + id: 40 + src: "0:0:0" + implemented: true + virtual: false + scope: 55 + kind: "fallback" + name: "" + visibility: "external" + stateMutability: "payable" + isConstructor: false + documentation: undefined + nameLocation: undefined + vParameters: ParameterList #33 + vReturnParameters: ParameterList #34 + vModifiers: Array(0) + vOverrideSpecifier: undefined + vBody: Block #39 + context: ASTContext #1000 + parent: ContractDefinition #55 + children: Array(3) [ ParameterList #33, ParameterList #34, Block #39 ] + vScope: ContractDefinition #55 + type: "FunctionDefinition" + firstChild: ParameterList #33 + lastChild: Block #39 + previousSibling: VariableDeclaration #32 + nextSibling: FunctionDefinition #54 + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + ParameterList #33 + id: 33 + src: "0:0:0" + context: ASTContext #1000 + parent: FunctionDefinition #40 + vParameters: Array(0) + children: Array(0) + type: "ParameterList" + firstChild: undefined + lastChild: undefined + previousSibling: undefined + nextSibling: ParameterList #34 + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + ParameterList #34 + id: 34 + src: "0:0:0" + context: ASTContext #1000 + parent: FunctionDefinition #40 + vParameters: Array(0) + children: Array(0) + type: "ParameterList" + firstChild: undefined + lastChild: undefined + previousSibling: ParameterList #33 + nextSibling: Block #39 + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + Block #39 + id: 39 + src: "0:0:0" + docString: undefined + context: ASTContext #1000 + parent: FunctionDefinition #40 + vStatements: Array(1) [ ExpressionStatement #38 ] + documentation: undefined + danglingDocumentation: undefined + children: Array(1) [ ExpressionStatement #38 ] + type: "Block" + firstChild: ExpressionStatement #38 + lastChild: ExpressionStatement #38 + previousSibling: ParameterList #34 + nextSibling: undefined + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + ExpressionStatement #38 + id: 38 + src: "0:0:0" + documentation: undefined + vExpression: Assignment #37 + context: ASTContext #1000 + parent: Block #39 + children: Array(1) [ Assignment #37 ] + type: "ExpressionStatement" + firstChild: Assignment #37 + lastChild: Assignment #37 + previousSibling: undefined + nextSibling: undefined + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + Assignment #37 + id: 37 + src: "0:0:0" + typeString: "int8" + operator: "=" + vLeftHandSide: Identifier #35 + vRightHandSide: Literal #36 + context: ASTContext #1000 + parent: ExpressionStatement #38 + children: Array(2) [ Identifier #35, Literal #36 ] + type: "Assignment" + firstChild: Identifier #35 + lastChild: Literal #36 + previousSibling: undefined + nextSibling: undefined + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + Identifier #35 + id: 35 + src: "0:0:0" + typeString: "int8" + name: "lastCall" + referencedDeclaration: 32 + context: ASTContext #1000 + parent: Assignment #37 + vReferencedDeclaration: VariableDeclaration #32 + vIdentifierType: "userDefined" + type: "Identifier" + children: Array(0) + firstChild: undefined + lastChild: undefined + previousSibling: undefined + nextSibling: Literal #36 + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + Literal #36 + id: 36 + src: "0:0:0" + typeString: "int_const 1" + kind: "number" + hexValue: "31" + value: "1" + subdenomination: undefined + context: ASTContext #1000 + parent: Assignment #37 + type: "Literal" + children: Array(0) + firstChild: undefined + lastChild: undefined + previousSibling: Identifier #35 + nextSibling: undefined + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + FunctionDefinition #54 + id: 54 + src: "0:0:0" + implemented: true + virtual: false + scope: 55 + kind: "function" + name: "id" + visibility: "public" + stateMutability: "nonpayable" + isConstructor: false + documentation: undefined + nameLocation: undefined + vParameters: ParameterList #43 + vReturnParameters: ParameterList #46 + vModifiers: Array(0) + vOverrideSpecifier: undefined + vBody: Block #53 + context: ASTContext #1000 + parent: ContractDefinition #55 + children: Array(3) [ ParameterList #43, ParameterList #46, Block #53 ] + vScope: ContractDefinition #55 + type: "FunctionDefinition" + firstChild: ParameterList #43 + lastChild: Block #53 + previousSibling: FunctionDefinition #40 + nextSibling: undefined + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + ParameterList #43 + id: 43 + src: "0:0:0" + context: ASTContext #1000 + parent: FunctionDefinition #54 + vParameters: Array(1) [ VariableDeclaration #42 ] + children: Array(1) [ VariableDeclaration #42 ] + type: "ParameterList" + firstChild: VariableDeclaration #42 + lastChild: VariableDeclaration #42 + previousSibling: undefined + nextSibling: ParameterList #46 + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + VariableDeclaration #42 + id: 42 + src: "0:0:0" + constant: false + indexed: false + name: "x" + scope: 54 + stateVariable: false + storageLocation: "default" + visibility: "internal" + mutability: "mutable" + typeString: "uint256" + documentation: undefined + nameLocation: undefined + vType: ElementaryTypeName #41 + vOverrideSpecifier: undefined + vValue: undefined + context: ASTContext #1000 + parent: ParameterList #43 + children: Array(1) [ ElementaryTypeName #41 ] + vScope: FunctionDefinition #54 + type: "VariableDeclaration" + firstChild: ElementaryTypeName #41 + lastChild: ElementaryTypeName #41 + previousSibling: undefined + nextSibling: undefined + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + ElementaryTypeName #41 + id: 41 + src: "0:0:0" + typeString: "uint256" + name: "uint" + stateMutability: "nonpayable" + context: ASTContext #1000 + parent: VariableDeclaration #42 + type: "ElementaryTypeName" + children: Array(0) + firstChild: undefined + lastChild: undefined + previousSibling: undefined + nextSibling: undefined + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + ParameterList #46 + id: 46 + src: "0:0:0" + context: ASTContext #1000 + parent: FunctionDefinition #54 + vParameters: Array(1) [ VariableDeclaration #45 ] + children: Array(1) [ VariableDeclaration #45 ] + type: "ParameterList" + firstChild: VariableDeclaration #45 + lastChild: VariableDeclaration #45 + previousSibling: ParameterList #43 + nextSibling: Block #53 + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + VariableDeclaration #45 + id: 45 + src: "0:0:0" + constant: false + indexed: false + name: "" + scope: 54 + stateVariable: false + storageLocation: "default" + visibility: "internal" + mutability: "mutable" + typeString: "uint256" + documentation: undefined + nameLocation: undefined + vType: ElementaryTypeName #44 + vOverrideSpecifier: undefined + vValue: undefined + context: ASTContext #1000 + parent: ParameterList #46 + children: Array(1) [ ElementaryTypeName #44 ] + vScope: FunctionDefinition #54 + type: "VariableDeclaration" + firstChild: ElementaryTypeName #44 + lastChild: ElementaryTypeName #44 + previousSibling: undefined + nextSibling: undefined + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + ElementaryTypeName #44 + id: 44 + src: "0:0:0" + typeString: "uint256" + name: "uint" + stateMutability: "nonpayable" + context: ASTContext #1000 + parent: VariableDeclaration #45 + type: "ElementaryTypeName" + children: Array(0) + firstChild: undefined + lastChild: undefined + previousSibling: undefined + nextSibling: undefined + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + Block #53 + id: 53 + src: "0:0:0" + docString: undefined + context: ASTContext #1000 + parent: FunctionDefinition #54 + vStatements: Array(2) [ ExpressionStatement #50, Return #52 ] + documentation: undefined + danglingDocumentation: undefined + children: Array(2) [ ExpressionStatement #50, Return #52 ] + type: "Block" + firstChild: ExpressionStatement #50 + lastChild: Return #52 + previousSibling: ParameterList #46 + nextSibling: undefined + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + ExpressionStatement #50 + id: 50 + src: "0:0:0" + documentation: undefined + vExpression: Assignment #49 + context: ASTContext #1000 + parent: Block #53 + children: Array(1) [ Assignment #49 ] + type: "ExpressionStatement" + firstChild: Assignment #49 + lastChild: Assignment #49 + previousSibling: undefined + nextSibling: Return #52 + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + Assignment #49 + id: 49 + src: "0:0:0" + typeString: "int8" + operator: "=" + vLeftHandSide: Identifier #47 + vRightHandSide: Literal #48 + context: ASTContext #1000 + parent: ExpressionStatement #50 + children: Array(2) [ Identifier #47, Literal #48 ] + type: "Assignment" + firstChild: Identifier #47 + lastChild: Literal #48 + previousSibling: undefined + nextSibling: undefined + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + Identifier #47 + id: 47 + src: "0:0:0" + typeString: "int8" + name: "lastCall" + referencedDeclaration: 32 + context: ASTContext #1000 + parent: Assignment #49 + vReferencedDeclaration: VariableDeclaration #32 + vIdentifierType: "userDefined" + type: "Identifier" + children: Array(0) + firstChild: undefined + lastChild: undefined + previousSibling: undefined + nextSibling: Literal #48 + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + Literal #48 + id: 48 + src: "0:0:0" + typeString: "int_const 2" + kind: "number" + hexValue: "32" + value: "2" + subdenomination: undefined + context: ASTContext #1000 + parent: Assignment #49 + type: "Literal" + children: Array(0) + firstChild: undefined + lastChild: undefined + previousSibling: Identifier #47 + nextSibling: undefined + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + Return #52 + id: 52 + src: "0:0:0" + documentation: undefined + functionReturnParameters: 18 + vExpression: Identifier #51 + context: ASTContext #1000 + parent: Block #53 + children: Array(1) [ Identifier #51 ] + vFunctionReturnParameters: ParameterList #18 + type: "Return" + firstChild: Identifier #51 + lastChild: Identifier #51 + previousSibling: ExpressionStatement #50 + nextSibling: undefined + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } + + Identifier #51 + id: 51 + src: "0:0:0" + typeString: "uint256" + name: "x" + referencedDeclaration: 42 + context: ASTContext #1000 + parent: Return #52 + vReferencedDeclaration: VariableDeclaration #42 + vIdentifierType: "userDefined" + type: "Identifier" + children: Array(0) + firstChild: undefined + lastChild: undefined + previousSibling: undefined + nextSibling: undefined + root: SourceUnit #56 + sourceInfo: Object { offset: 0, length: 0, sourceIndex: 0 } diff --git a/test/samples/solidity/issue_132_fun_kind.sol b/test/samples/solidity/issue_132_fun_kind.sol new file mode 100644 index 00000000..6864f68e --- /dev/null +++ b/test/samples/solidity/issue_132_fun_kind.sol @@ -0,0 +1,15 @@ +pragma solidity 0.4.24; + +contract FBNoArgs { + int8 public lastCall = 0; + + function() external payable { + lastCall = 1; + } + + function id(uint x) public returns (uint) { + lastCall = 2; + return x; + } +} +