Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception thrown when calling an annotated function from another annotation #36

Closed
cd1m0 opened this issue Apr 22, 2021 · 0 comments · Fixed by #37
Closed

Exception thrown when calling an annotated function from another annotation #36

cd1m0 opened this issue Apr 22, 2021 · 0 comments · Fixed by #37
Assignees
Labels
bug Something isn't working

Comments

@cd1m0
Copy link
Collaborator

cd1m0 commented Apr 22, 2021

Instrumenting the following sample:

contract CallinInstrumentedFun {
    uint x = 1;
    /// if_succeeds res > 0;
    function getX() public view returns (uint res) {
        return x;
    }

    /// if_succeeds res == x + getX();
    function inc(uint x) public returns (uint res) {
        return x + getX();
    }
}

Produces this exception:

/home/dimo/work/consensys/scribble-clean/dist/bin/scribble.js:574
            throw e;
            ^

Error: Internal error: variable id getX has different name from underlying variable FunctionDefinition #208
    id: 208
    src: "2967:72:0"
    type: "FunctionDefinition"
    implemented: true
    virtual: false
    scope: 204
    kind: "function"
    name: "_original_CallinInstrumentedFun_getX"
    visibility: "private"
    stateMutability: "view"
    isConstructor: false
    documentation: undefined
    nameLocation: undefined
    vParameters: ParameterList #210
    vReturnParameters: ParameterList #211
    vModifiers: Array(0)
    vOverrideSpecifier: undefined
    vBody: Block #214
    context: ASTContext #2
    parent: ContractDefinition #204
    <getter> children: Array(3) [ ParameterList #210, ParameterList #211, Block #214 ]
    <getter> vScope: ContractDefinition #204
    <getter> canonicalSignature: "_original_CallinInstrumentedFun_getX()"
    <getter> canonicalSignatureHash: "28cc8fb6"
    <getter> firstChild: ParameterList #210
    <getter> lastChild: Block #214
    <getter> previousSibling: FunctionDefinition #804
    <getter> nextSibling: FunctionDefinition #846
    <getter> root: SourceUnit #0
    <getter> sourceInfo: Object { offset: 2967, length: 72, sourceIndex: 0 }

    at generateIdAST (/home/dimo/work/consensys/scribble-clean/dist/instrumenter/transpile.js:129:15)
    at generateExprAST (/home/dimo/work/consensys/scribble-clean/dist/instrumenter/transpile.js:154:16)
    at generateExprAST (/home/dimo/work/consensys/scribble-clean/dist/instrumenter/transpile.js:215:22)
    at generateExprAST (/home/dimo/work/consensys/scribble-clean/dist/instrumenter/transpile.js:188:23)
    at Object.generateExprAST (/home/dimo/work/consensys/scribble-clean/dist/instrumenter/transpile.js:188:23)
    at /home/dimo/work/consensys/scribble-clean/dist/instrumenter/instrument.js:436:74
    at Array.map (<anonymous>)
    at generateExpressions (/home/dimo/work/consensys/scribble-clean/dist/instrumenter/instrument.js:436:44)
    at FunctionInstrumenter.instrument (/home/dimo/work/consensys/scribble-clean/dist/instrumenter/instrument.js:792:29)
    at instrumentFiles (/home/dimo/work/consensys/scribble-clean/dist/bin/scribble.js:161:34)

This is due to an overzealous check in generateIdAST. Fix is to remove the check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants