Open fvictorio opened 2 years ago
+1 to not adding new options. If I may suggest, these kind of transformations are more useful in a linter (solhint?), where it works with the user to educate/produce better code. For formatting, I think it should focus on just layout/whitespaces.
Out of curiosity @fvictorio why are we formatting it this way? is it based on how we read the AST?
It can be either a thing we did (consciously or not), or it could be that the AST doesn't have enough information to tell apart between these semantically equivalent statements.
Found another one: byte
is rewritten as bytes1
.
I actually do not think they are semantically the same wrt the solidity compiler, i think if you do:
import * as {Bar} from "./Bar.sol"
and
import "./Bar.sol" as Bar;
they are the same? Imports are not 1:1 wrt the javascript module spec which solidity states its suppose to model after (as you can import via URL)
https://html.spec.whatwg.org/multipage/webappapis.html#integration-with-the-javascript-module-system
This
is re-written as
Those two statements are (I think?) semantically equivalent, but I think this is too opinionated. We should keep in mind that prettier solidity is not only being used by smart contract developers. For example, @OmarTawfik is considering using it to generate snippets in an upcoming solidity specification, and re-writes like this one make it impossible to use for that use case.
We could have an option for this, but I think at this point everyone knows I really, really don't like adding new options :sweat_smile: