prettier-plugin-solidity icon indicating copy to clipboard operation
prettier-plugin-solidity copied to clipboard

Error on multiple return values in assembly

Open cxkoda opened this issue 4 years ago • 1 comments

contract C {
    function foo() public {
        assembly {
            function bar() -> x, y { }

            let x
            let y

            x, y := bar()
        }
    }
}

results in

$ prettier --check "contracts/**/*.sol"
contracts/contract.sol
[error] contracts/contract.sol: Error: extraneous input ',' expecting {'from', '{', '}', '(', 'error', 'for', 'function', 'address', 'calldata', 'if', 'assembly', 'return', 'revert', 'byte', 'let', '=:', 'switch', 'callback', DecimalNumber, HexNumber, HexLiteralFragment, 'break', 'continue', 'leave', 'payable', 'constructor', 'receive', Identifier, StringLiteralFragment} (11:13)
[error]     at Object.parse (/node_modules/prettier-plugin-solidity/node_modules/@solidity-parser/parser/dist/index.cjs.js:36867:11)
[error]     at Object.parse (/node_modules/prettier-plugin-solidity/src/parser.js:18:25)
[error]     at Object.parse$a [as parse] (/node_modules/prettier/index.js:12513:19)
[error]     at coreFormat (/node_modules/prettier/index.js:14044:16)
[error]     at formatWithCursor$1 (/node_modules/prettier/index.js:14284:14)
[error]     at Object.formatWithCursor (/node_modules/prettier/index.js:59304:12)
[error]     at format$1 (/node_modules/prettier/bin-prettier.js:16953:21)
[error]     at Object.formatFiles$1 [as formatFiles] (/node_modules/prettier/bin-prettier.js:17067:16)
[error]     at async main (/node_modules/prettier/bin-prettier.js:18925:5)
[error]     at async Object.run (/node_modules/prettier/bin-prettier.js:18868:5)

Also trying to wrap the respective lines with an ignore has no effect.

contract C {
    function foo() public {
        assembly {
            function bar() -> x, y { }

            let x
            let y

            // prettier-ignore
            {
                x, y := bar()
            }
        }
    }
}

cxkoda avatar Oct 13 '21 16:10 cxkoda

https://github.com/solidity-parser/antlr/pull/11 will fix the problem.

aoi-w avatar Jul 12 '22 14:07 aoi-w