diff --git a/src/printer.js b/src/printer.js index e52fa8edf..94edfd80a 100644 --- a/src/printer.js +++ b/src/printer.js @@ -33,7 +33,10 @@ function genericPrint(path, options, print) { let doc; switch (node.type) { case 'SourceUnit': - return printPreservingEmptyLines(path, 'children', options, print); + return concat([ + printPreservingEmptyLines(path, 'children', options, print), + line + ]); case 'PragmaDirective': return concat(['pragma ', node.name, ' ', node.value, ';']); case 'ImportDirective': @@ -73,7 +76,6 @@ function genericPrint(path, options, print) { ]); } parts.push('}'); - parts.push(line); return concat(parts); } diff --git a/tests/AllSolidityFeatures/__snapshots__/jsfmt.spec.js.snap b/tests/AllSolidityFeatures/__snapshots__/jsfmt.spec.js.snap index f174177af..f003bfb90 100644 --- a/tests/AllSolidityFeatures/__snapshots__/jsfmt.spec.js.snap +++ b/tests/AllSolidityFeatures/__snapshots__/jsfmt.spec.js.snap @@ -430,7 +430,6 @@ interface i { function f(); } - contract c { function c() { val1 = 1 wei; // 1 @@ -444,7 +443,6 @@ contract c { uint256 val4; } - contract test { enum ActionChoices {GoLeft, GoRight, GoStraight, SitStill} @@ -457,19 +455,16 @@ contract test { ActionChoices choices; } - contract Base { function Base(uint i) { m_i = i; } uint public m_i; } - contract Derived is Base(0) { function Derived(uint i) Base(i) {} } - contract C { uint248 x; // 31 bytes: slot 0, offset 0 uint16 y; // 2 bytes: slot 1, offset 0 (does not fit in slot 0) @@ -485,7 +480,6 @@ contract C { uint8 gamma; // 1 byte, slot 7 (start new slot after array) } - contract test { function f(uint x, uint y) returns (uint z) { var c = x + 3; @@ -494,14 +488,12 @@ contract test { } } - contract test { function f(uint x, uint y) returns (uint z) { return 10; } } - contract c { function() returns (uint) { return g(8); @@ -519,7 +511,6 @@ contract c { mapping(uint => uint) data; } - contract Sharer { function sendHalf(address addr) returns (uint balance) { if (!addr.send(msg.value / 2)) throw; // also reverts the transfer to Sharer @@ -527,7 +518,6 @@ contract Sharer { } } - /// @dev Models a modifiable and iterable set of uint values. library IntegerSet { struct data { @@ -581,7 +571,6 @@ library IntegerSet { } } - /// How to use it: contract User { /// Just a struct holding our data. @@ -605,7 +594,6 @@ contract User { } } - // This broke it at one point (namely the modifiers). contract DualIndex { mapping(uint => mapping(uint => uint)) data; @@ -633,26 +621,20 @@ contract DualIndex { } } - contract A {} - contract B {} - contract C is A, B {} - contract TestPrivate { uint private value; } - contract TestInternal { uint internal value; } - contract FromSolparse is A, B, TestPrivate, TestInternal { function() { uint a = 6 ** 9; @@ -661,7 +643,6 @@ contract FromSolparse is A, B, TestPrivate, TestInternal { } } - contract CommentedOutFunction { // FYI: This empty function, as well as the commented // out function below (bad code) is important to this test. @@ -673,25 +654,21 @@ contract CommentedOutFunction { } - library VarHasBrackets { string constant specialRight = "}"; //string storage specialLeft = "{"; } - library UsingExampleLibrary { function sum(uint[] storage self) returns (uint s) { for (uint i = 0; i < self.length; i++) s += self[i]; } } - contract UsingExampleContract { using UsingExampleLibrary for uint[]; } - contract NewStuff { uint[] b; @@ -701,13 +678,11 @@ contract NewStuff { } } - // modifier with expression contract MyContract { function fun() mymodifier(foo.bar()) {} } - library GetCode { function at(address _addr) returns (bytes o_code) { assembly { @@ -726,7 +701,6 @@ library GetCode { } } - contract assemblyLocalBinding { function test() { assembly { @@ -738,7 +712,6 @@ contract assemblyLocalBinding { } } - contract assemblyReturn { uint a = 10; @@ -752,12 +725,10 @@ contract assemblyReturn { } } - contract usesConst { uint const = 0; } - contract memoryArrays { uint seven = 7; @@ -771,7 +742,6 @@ contract memoryArrays { } } - contract DeclarativeExpressions { uint a; uint b = 7; @@ -793,7 +763,6 @@ contract DeclarativeExpressions { } } - contract VariableDeclarationTuple { function getMyTuple() returns (bool, bool) { return (true, false); @@ -810,13 +779,11 @@ contract VariableDeclarationTuple { } } - contract TypeIndexSpacing { uint[7] x; uint[] y; } - contract Ballot { struct Voter { uint weight; @@ -844,7 +811,6 @@ contract Ballot { Voter airbnb = Voter({weight: 2, voted: true}); } - contract multilineReturn { function a() returns (uint x) { return 5; diff --git a/tests/SampleCrowdsale/__snapshots__/jsfmt.spec.js.snap b/tests/SampleCrowdsale/__snapshots__/jsfmt.spec.js.snap index 66974ba0b..fc174ca55 100644 --- a/tests/SampleCrowdsale/__snapshots__/jsfmt.spec.js.snap +++ b/tests/SampleCrowdsale/__snapshots__/jsfmt.spec.js.snap @@ -68,7 +68,6 @@ contract SampleCrowdsaleToken is MintableToken { } - /** * @title SampleCrowdsale * @dev This is an example of a fully fledged crowdsale.