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

about exponentiation

Open emretepedev opened this issue 1 year ago • 4 comments

I want to format exponentiation symbols like in JavaScript. Also OpenZeppelin uses it like this:

Expected Behaviour

function foo(int x) public returns (int) {
  return x ** x;
}

Actual Behaviour

function foo(int x) public returns (int) {
  return x**x; // here
}

Maybe it should be changed in the config?

emretepedev avatar Jul 13 '22 15:07 emretepedev

Hi,

We decided on #174 to not to use an option for this.

We try to use as few options as possible as this is easier for maintenance.

The only use of exponentiation I could find in the OpenZeppelin contracts was here.

Janther avatar Jul 14 '22 02:07 Janther

Uhm, the fact that prettier formats it that way in javascript makes me think we might want to reconsider this. On the other hand, this plugin is already used by a lot of projects, and forcing a re-format without a good reason might not be a great idea.

I say we keep this issue open for now just in case. Thanks for the data point @emretepedev.

fvictorio avatar Jul 15 '22 21:07 fvictorio

fwiw the solidity style guide only makes a distinction when used to denote precedence.

sambacha avatar Jul 15 '22 22:07 sambacha

Hi,

We decided on #174 to not to use an option for this.

We try to use as few options as possible as this is easier for maintenance.

The only use of exponentiation I could find in the OpenZeppelin contracts was here.

Hi @Janther I saw in OpenZeppelin's Contracts Wizard, not in contract. Open in Remix (copied from the oz contract wizard). Also, I saw in ethernaut contracts.

emretepedev avatar Jul 16 '22 10:07 emretepedev

Closing this, the exponentiation operator is now surrounded with spaces.

fvictorio avatar Nov 03 '22 07:11 fvictorio