Skip to content

Commit 2e9149b

Browse files
authored
Breaking changes in v0.8.0 (#459)
* Fixing silent errors since v0.8.0 * missing snapshot
1 parent 6c56faa commit 2e9149b

File tree

4 files changed

+102
-97
lines changed

4 files changed

+102
-97
lines changed

src/parser.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,18 @@ function parse(text, parsers, options) {
2929
: `hex"${ctx.value.slice(4, -1)}"`;
3030
},
3131
ElementaryTypeName(ctx) {
32+
// We avoid making changes for bytes1 since the type 'byte' was removed
33+
// in v0.8.0
34+
// See the breaking changes in https://docs.soliditylang.org/en/v0.8.0/080-breaking-changes.html#silent-changes-of-the-semantics
35+
// The type byte has been removed. It was an alias of bytes1.
36+
// TODO once we decide to keep track of the pragma, we can implement this again.
37+
3238
if (options.explicitTypes === 'always') {
3339
if (ctx.name === 'uint') ctx.name = 'uint256';
3440
if (ctx.name === 'int') ctx.name = 'int256';
35-
if (ctx.name === 'byte') ctx.name = 'bytes1';
3641
} else if (options.explicitTypes === 'never') {
3742
if (ctx.name === 'uint256') ctx.name = 'uint';
3843
if (ctx.name === 'int256') ctx.name = 'int';
39-
if (ctx.name === 'bytes1') ctx.name = 'byte';
4044
}
4145
},
4246
BinaryOperation(ctx) {
@@ -56,7 +60,12 @@ function parse(text, parsers, options) {
5660
ctx.left = tryHug(ctx.left, ['*', '/', '%']);
5761
break;
5862
case '**':
59-
ctx.left = tryHug(ctx.left, ['**']);
63+
// We avoid making changes here since the order of precedence of the
64+
// operators for ** changed in v0.8.0
65+
// See the breaking changes in https://docs.soliditylang.org/en/v0.8.0/080-breaking-changes.html#silent-changes-of-the-semantics
66+
// Exponentiation is right associative, i.e., the expression a**b**c
67+
// is parsed as a**(b**c). Before 0.8.0, it was parsed as (a**b)**c.
68+
// TODO once we decide to keep track of the pragma, we can implement this again.
6069
break;
6170
case '<<':
6271
case '>>':

tests/BinaryOperators/__snapshots__/jsfmt.spec.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ contract Parentheses {
880880
a**b * c;
881881
a**b / c;
882882
a**b % c;
883-
(a**b)**c;
883+
a**b**c;
884884
(a**b) << c;
885885
(a**b) >> c;
886886
(a**b) & c;
Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,36 @@
1-
pragma solidity 0.5.8;
2-
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity 0.8.3;
33

44
contract VariableTypesMixed {
55
uint256 public a;
66
int256 public b;
7-
bytes1 public c;
87
uint public e;
98
int public f;
10-
byte public g;
119

1210
struct S {
1311
uint a;
1412
int b;
15-
byte c;
1613
uint256 e;
1714
int256 f;
18-
bytes1 g;
1915
}
2016

21-
event Event(uint _a, int256 _b, bytes1 _c, uint256 _e, int _f, byte _g);
17+
event Event(uint _a, int256 _b, uint256 _e, int _f);
2218

23-
function func(uint256 _a, int256 _b, byte _c, uint _e, int _f, bytes1 _g)
19+
function func(
20+
uint256 _a,
21+
int256 _b,
22+
uint _e,
23+
int _f
24+
)
2425
public
25-
returns (uint, int256, byte, uint256, int, bytes1)
26+
returns (
27+
uint,
28+
int256,
29+
uint256,
30+
int
31+
)
2632
{
27-
emit Event(_a, _b, _c, _e, _f, _g);
28-
return (_a, _b, _c, _e, _f, _g);
33+
emit Event(_a, _b, _e, _f);
34+
return (_a, _b, _e, _f);
2935
}
3036
}

0 commit comments

Comments
 (0)